Category: Matlab
Category Archives: Matlab
shared matlab-engine python connections occationally fail with an Unable to connect to MATLAB session error
On a RHEL7 platform, we are running a shared (synchronous) MATLAB session as a systemd service. We are also running 3 python systemd services that connect to the shared matlab engine using matlab_eng = matlab.engine.connect_matlab("OUR_SESSION_NAME_HERE"). After successfully connecting to the shared matlab-engine, the python service will do some MATLAB processing, then do a matlab_eng.quit() to disconnect from the shared matlab-engine. I have 4 questions that I hope somebody could answer. See below.
Regards Debbie
Is matlab_eng.quit() the correct way to disconnect from the shared matlab-engine?
Can you confirm that each of the 3 python systemd services will have it’s own MATLAB workspace?
After our python services have run awhile, we start seeing trouble connecting to the shared matlab-engine. The stack trace looks similar to as shown below. Why would these connection errors only occationally occur and how can we fix this? We have assumed that each of our python processes can use the shared matlab-engine concurrently, is this not correct?
As a follow-up to question 3, why is _future.result showing up in the trace? We started a synchronous matlab-engine, the documentation mentions future results only with respect to asynchronous matlab-engines.
<class ‘matlab.engine.EngineError’>
Unable to connect to MATLAB session ‘OUR_SESSION_NAME_HERE’.
matlab_eng = matlab.engine.connect_matlab(‘OUR_SESSION_NAME_HERE’)
!! File "/usr/lib/python2.7/site-packages/matlab/engine/__init__.py", line 182, in connect_matlab
eng = future.result()
!! File "/usr/lib/python2.7/site-packages/matlab/engine/futureresult.py", line 67, in result
return self.__future.result(timeout)
!! File "/usr/lib/python2.7/site-packages/matlab/engine/matlabfuture.py", line 87, in result
handle = pythonengine.getMATLAB(self._future)On a RHEL7 platform, we are running a shared (synchronous) MATLAB session as a systemd service. We are also running 3 python systemd services that connect to the shared matlab engine using matlab_eng = matlab.engine.connect_matlab("OUR_SESSION_NAME_HERE"). After successfully connecting to the shared matlab-engine, the python service will do some MATLAB processing, then do a matlab_eng.quit() to disconnect from the shared matlab-engine. I have 4 questions that I hope somebody could answer. See below.
Regards Debbie
Is matlab_eng.quit() the correct way to disconnect from the shared matlab-engine?
Can you confirm that each of the 3 python systemd services will have it’s own MATLAB workspace?
After our python services have run awhile, we start seeing trouble connecting to the shared matlab-engine. The stack trace looks similar to as shown below. Why would these connection errors only occationally occur and how can we fix this? We have assumed that each of our python processes can use the shared matlab-engine concurrently, is this not correct?
As a follow-up to question 3, why is _future.result showing up in the trace? We started a synchronous matlab-engine, the documentation mentions future results only with respect to asynchronous matlab-engines.
<class ‘matlab.engine.EngineError’>
Unable to connect to MATLAB session ‘OUR_SESSION_NAME_HERE’.
matlab_eng = matlab.engine.connect_matlab(‘OUR_SESSION_NAME_HERE’)
!! File "/usr/lib/python2.7/site-packages/matlab/engine/__init__.py", line 182, in connect_matlab
eng = future.result()
!! File "/usr/lib/python2.7/site-packages/matlab/engine/futureresult.py", line 67, in result
return self.__future.result(timeout)
!! File "/usr/lib/python2.7/site-packages/matlab/engine/matlabfuture.py", line 87, in result
handle = pythonengine.getMATLAB(self._future) On a RHEL7 platform, we are running a shared (synchronous) MATLAB session as a systemd service. We are also running 3 python systemd services that connect to the shared matlab engine using matlab_eng = matlab.engine.connect_matlab("OUR_SESSION_NAME_HERE"). After successfully connecting to the shared matlab-engine, the python service will do some MATLAB processing, then do a matlab_eng.quit() to disconnect from the shared matlab-engine. I have 4 questions that I hope somebody could answer. See below.
Regards Debbie
Is matlab_eng.quit() the correct way to disconnect from the shared matlab-engine?
Can you confirm that each of the 3 python systemd services will have it’s own MATLAB workspace?
After our python services have run awhile, we start seeing trouble connecting to the shared matlab-engine. The stack trace looks similar to as shown below. Why would these connection errors only occationally occur and how can we fix this? We have assumed that each of our python processes can use the shared matlab-engine concurrently, is this not correct?
As a follow-up to question 3, why is _future.result showing up in the trace? We started a synchronous matlab-engine, the documentation mentions future results only with respect to asynchronous matlab-engines.
<class ‘matlab.engine.EngineError’>
Unable to connect to MATLAB session ‘OUR_SESSION_NAME_HERE’.
matlab_eng = matlab.engine.connect_matlab(‘OUR_SESSION_NAME_HERE’)
!! File "/usr/lib/python2.7/site-packages/matlab/engine/__init__.py", line 182, in connect_matlab
eng = future.result()
!! File "/usr/lib/python2.7/site-packages/matlab/engine/futureresult.py", line 67, in result
return self.__future.result(timeout)
!! File "/usr/lib/python2.7/site-packages/matlab/engine/matlabfuture.py", line 87, in result
handle = pythonengine.getMATLAB(self._future) matlab-engine python MATLAB Answers — New Questions
Adding MAVLINK messages for an external groundstation to use in telemetry (RFD-900)
Is there a way to easily add values saved in a simulink code to the message list that external ground station programs can receive and use as telemetry.
I currently have a set of saved data points through a custom uORB message that are calculated in the simulink flight controller but I would like the freedom to also have these values be telemetered to programs like mission planner or Qground control. Ive explored some options about creating new mavlink messages but this process is incredibly cumbersome and way out my depth to successfully implement since it involves invidiaully editing more than 5 different files in the base firmware file structure. Is there a reliable way using simulink blocks to create these new messages to be included
The current setup is using a Pixhawk 6x with an RFD 900 for telemetry.Is there a way to easily add values saved in a simulink code to the message list that external ground station programs can receive and use as telemetry.
I currently have a set of saved data points through a custom uORB message that are calculated in the simulink flight controller but I would like the freedom to also have these values be telemetered to programs like mission planner or Qground control. Ive explored some options about creating new mavlink messages but this process is incredibly cumbersome and way out my depth to successfully implement since it involves invidiaully editing more than 5 different files in the base firmware file structure. Is there a reliable way using simulink blocks to create these new messages to be included
The current setup is using a Pixhawk 6x with an RFD 900 for telemetry. Is there a way to easily add values saved in a simulink code to the message list that external ground station programs can receive and use as telemetry.
I currently have a set of saved data points through a custom uORB message that are calculated in the simulink flight controller but I would like the freedom to also have these values be telemetered to programs like mission planner or Qground control. Ive explored some options about creating new mavlink messages but this process is incredibly cumbersome and way out my depth to successfully implement since it involves invidiaully editing more than 5 different files in the base firmware file structure. Is there a reliable way using simulink blocks to create these new messages to be included
The current setup is using a Pixhawk 6x with an RFD 900 for telemetry. mavlink, telemetry, rfd900, uorb, messages MATLAB Answers — New Questions
Question about making simulink block for opencv_contrib
Hello Everyone,
I have a problem that I need to use opencv_contrib for aruco marker detection in simulink, but opencv importer doesn’t seem to be able to make a simulink block for opencv_contrib.
I would like to know if there are any successful imports using opencv importer for opencv_contrib, and if not are there any other ways to use opencv_contrib in simulink. Although I can use opencv functions in matlab using the mex interface.Hello Everyone,
I have a problem that I need to use opencv_contrib for aruco marker detection in simulink, but opencv importer doesn’t seem to be able to make a simulink block for opencv_contrib.
I would like to know if there are any successful imports using opencv importer for opencv_contrib, and if not are there any other ways to use opencv_contrib in simulink. Although I can use opencv functions in matlab using the mex interface. Hello Everyone,
I have a problem that I need to use opencv_contrib for aruco marker detection in simulink, but opencv importer doesn’t seem to be able to make a simulink block for opencv_contrib.
I would like to know if there are any successful imports using opencv importer for opencv_contrib, and if not are there any other ways to use opencv_contrib in simulink. Although I can use opencv functions in matlab using the mex interface. opencv, aruco, simulink MATLAB Answers — New Questions
Triangle clustering of .stl file
Hello everyone,
I am asking help to the MATLAB community since my head is burning 🙁
So I have stored two matrices F(mx3) and N(ux3), where u is 3 times m. The first matrix F contains the triangles of an .stl file, namely it containes, in each row, the indices of the rows of matrix N where the X, Y, and Z coordinate are stored. So, for example, if F(1,:) = [1 2 3], it means that the coordinates of the vertices of the first triangle have to be found in rows 1,2, and 3 of matrix N.
Plotting the triangles we have this situation:
Now what i want to do is divide the triangles in different regions (in this case 3, but the number of regions should not be a user input).
I have been able to identify the triangles wich lies on the border writing a small algorithm that search, for each triangle, what are the adjacent triangles (looking for the common edges). All the triangles that only have 1 or 2 adjacent triangles are stored as "Border Triangles".
Here, unfortunately, is where i stop. I have thought to use some graph traversal methods to identify the regions but i am not familiar with this type of techniques.
Any suggestions?
I am not attaching any dataset since it will be to heavy and probably to much confusing.
Hoping to find an answer here 🙂
ThanksHello everyone,
I am asking help to the MATLAB community since my head is burning 🙁
So I have stored two matrices F(mx3) and N(ux3), where u is 3 times m. The first matrix F contains the triangles of an .stl file, namely it containes, in each row, the indices of the rows of matrix N where the X, Y, and Z coordinate are stored. So, for example, if F(1,:) = [1 2 3], it means that the coordinates of the vertices of the first triangle have to be found in rows 1,2, and 3 of matrix N.
Plotting the triangles we have this situation:
Now what i want to do is divide the triangles in different regions (in this case 3, but the number of regions should not be a user input).
I have been able to identify the triangles wich lies on the border writing a small algorithm that search, for each triangle, what are the adjacent triangles (looking for the common edges). All the triangles that only have 1 or 2 adjacent triangles are stored as "Border Triangles".
Here, unfortunately, is where i stop. I have thought to use some graph traversal methods to identify the regions but i am not familiar with this type of techniques.
Any suggestions?
I am not attaching any dataset since it will be to heavy and probably to much confusing.
Hoping to find an answer here 🙂
Thanks Hello everyone,
I am asking help to the MATLAB community since my head is burning 🙁
So I have stored two matrices F(mx3) and N(ux3), where u is 3 times m. The first matrix F contains the triangles of an .stl file, namely it containes, in each row, the indices of the rows of matrix N where the X, Y, and Z coordinate are stored. So, for example, if F(1,:) = [1 2 3], it means that the coordinates of the vertices of the first triangle have to be found in rows 1,2, and 3 of matrix N.
Plotting the triangles we have this situation:
Now what i want to do is divide the triangles in different regions (in this case 3, but the number of regions should not be a user input).
I have been able to identify the triangles wich lies on the border writing a small algorithm that search, for each triangle, what are the adjacent triangles (looking for the common edges). All the triangles that only have 1 or 2 adjacent triangles are stored as "Border Triangles".
Here, unfortunately, is where i stop. I have thought to use some graph traversal methods to identify the regions but i am not familiar with this type of techniques.
Any suggestions?
I am not attaching any dataset since it will be to heavy and probably to much confusing.
Hoping to find an answer here 🙂
Thanks triangles, clustering, stl, region identification, graph traversal, cluster MATLAB Answers — New Questions
how to create channel attention layer in matlab.
classdef ChannelAttentionLayer < nnet.layer.Layer
properties
% Reduction ratio used in the channel attention mechanism
ReductionRatio
end
properties (Learnable)
% Layer learnable parameters
Weights1
Bias1
Weights2
Bias2
end
methods
function layer = ChannelAttentionLayer(reduction_ratio, input_channels, name)
% Constructor for ChannelAttentionLayer
layer.Name = name;
layer.ReductionRatio = reduction_ratio;
% Calculate reduced channels based on reduction ratio
reduced_channels = max(1, round(input_channels / reduction_ratio));
% Initialize weights and biases
layer.Weights1 = randn([1, 1, input_channels, reduced_channels], ‘single’);
layer.Bias1 = zeros([1, 1, reduced_channels], ‘single’);
layer.Weights2 = randn([1, 1, reduced_channels, input_channels], ‘single’);
layer.Bias2 = zeros([1, 1, input_channels], ‘single’);
end
function Z = forward(layer, X)
% Forward pass for training mode
% Ensure X is a dlarray
X = dlarray(X);
% Get input size
[H, W, C] = size(X);
% Global Average Pooling (GAP)
avg_pool = mean(X, [1, 2]); % Mean over height and width
avg_pool = reshape(avg_pool, [1, 1, C]); % Reshape to [1, 1, Channels]
% Global Max Pooling (GMP)
max_pool = max(X, [], [1, 2]); % Max over height and width
max_pool = reshape(max_pool, [1, 1, C]); % Reshape to [1, 1, Channels]
% First fully connected layer applied to both avg and max pooled outputs
avg_out = fullyconnect(avg_pool, layer.Weights1, layer.Bias1, C, layer.ReductionRatio);
max_out = fullyconnect(max_pool, layer.Weights1, layer.Bias1, C, layer.ReductionRatio);
% Apply ReLU
avg_out = relu(avg_out);
max_out = relu(max_out);
% Second fully connected layer
avg_out = fullyconnect(avg_out, layer.Weights2, layer.Bias2, layer.ReductionRatio, C);
max_out = fullyconnect(max_out, layer.Weights2, layer.Bias2, layer.ReductionRatio, C);
% Combine average and max pooled outputs
Z = avg_out + max_out;
% Apply sigmoid to get attention weights
Z = sigmoid(Z);
% Reshape attention map and multiply with input
Z = reshape(Z, [1, 1, C]);
Z = X .* Z;
% Ensure Z is unformatted
Z = dlarray(Z);
end
function Z = predict(layer, X)
% Predict pass for inference mode
Z = forward(layer, X);
end
end
end
% Fully connected operation for 1×1 conv
function out = fullyconnect(input, weights, bias, input_channels, output_channels)
% Ensure the number of input channels matches the weights’ channels
[H, W, C_in] = size(input);
[~, ~, C, ~] = size(weights);
if C_in ~= C
error(‘Number of channels in input and weights do not match.’);
end
% Flatten input dimensions
input_reshaped = reshape(input, [], C_in); % Flatten spatial dimensions
% Perform matrix multiplication and add bias
weights_reshaped = reshape(weights, [C_in, output_channels]);
out = input_reshaped * weights_reshaped + reshape(bias, [1, output_channels]);
% Reshape back to original dimensions
out = reshape(out, [1, 1, output_channels]);
endclassdef ChannelAttentionLayer < nnet.layer.Layer
properties
% Reduction ratio used in the channel attention mechanism
ReductionRatio
end
properties (Learnable)
% Layer learnable parameters
Weights1
Bias1
Weights2
Bias2
end
methods
function layer = ChannelAttentionLayer(reduction_ratio, input_channels, name)
% Constructor for ChannelAttentionLayer
layer.Name = name;
layer.ReductionRatio = reduction_ratio;
% Calculate reduced channels based on reduction ratio
reduced_channels = max(1, round(input_channels / reduction_ratio));
% Initialize weights and biases
layer.Weights1 = randn([1, 1, input_channels, reduced_channels], ‘single’);
layer.Bias1 = zeros([1, 1, reduced_channels], ‘single’);
layer.Weights2 = randn([1, 1, reduced_channels, input_channels], ‘single’);
layer.Bias2 = zeros([1, 1, input_channels], ‘single’);
end
function Z = forward(layer, X)
% Forward pass for training mode
% Ensure X is a dlarray
X = dlarray(X);
% Get input size
[H, W, C] = size(X);
% Global Average Pooling (GAP)
avg_pool = mean(X, [1, 2]); % Mean over height and width
avg_pool = reshape(avg_pool, [1, 1, C]); % Reshape to [1, 1, Channels]
% Global Max Pooling (GMP)
max_pool = max(X, [], [1, 2]); % Max over height and width
max_pool = reshape(max_pool, [1, 1, C]); % Reshape to [1, 1, Channels]
% First fully connected layer applied to both avg and max pooled outputs
avg_out = fullyconnect(avg_pool, layer.Weights1, layer.Bias1, C, layer.ReductionRatio);
max_out = fullyconnect(max_pool, layer.Weights1, layer.Bias1, C, layer.ReductionRatio);
% Apply ReLU
avg_out = relu(avg_out);
max_out = relu(max_out);
% Second fully connected layer
avg_out = fullyconnect(avg_out, layer.Weights2, layer.Bias2, layer.ReductionRatio, C);
max_out = fullyconnect(max_out, layer.Weights2, layer.Bias2, layer.ReductionRatio, C);
% Combine average and max pooled outputs
Z = avg_out + max_out;
% Apply sigmoid to get attention weights
Z = sigmoid(Z);
% Reshape attention map and multiply with input
Z = reshape(Z, [1, 1, C]);
Z = X .* Z;
% Ensure Z is unformatted
Z = dlarray(Z);
end
function Z = predict(layer, X)
% Predict pass for inference mode
Z = forward(layer, X);
end
end
end
% Fully connected operation for 1×1 conv
function out = fullyconnect(input, weights, bias, input_channels, output_channels)
% Ensure the number of input channels matches the weights’ channels
[H, W, C_in] = size(input);
[~, ~, C, ~] = size(weights);
if C_in ~= C
error(‘Number of channels in input and weights do not match.’);
end
% Flatten input dimensions
input_reshaped = reshape(input, [], C_in); % Flatten spatial dimensions
% Perform matrix multiplication and add bias
weights_reshaped = reshape(weights, [C_in, output_channels]);
out = input_reshaped * weights_reshaped + reshape(bias, [1, output_channels]);
% Reshape back to original dimensions
out = reshape(out, [1, 1, output_channels]);
end classdef ChannelAttentionLayer < nnet.layer.Layer
properties
% Reduction ratio used in the channel attention mechanism
ReductionRatio
end
properties (Learnable)
% Layer learnable parameters
Weights1
Bias1
Weights2
Bias2
end
methods
function layer = ChannelAttentionLayer(reduction_ratio, input_channels, name)
% Constructor for ChannelAttentionLayer
layer.Name = name;
layer.ReductionRatio = reduction_ratio;
% Calculate reduced channels based on reduction ratio
reduced_channels = max(1, round(input_channels / reduction_ratio));
% Initialize weights and biases
layer.Weights1 = randn([1, 1, input_channels, reduced_channels], ‘single’);
layer.Bias1 = zeros([1, 1, reduced_channels], ‘single’);
layer.Weights2 = randn([1, 1, reduced_channels, input_channels], ‘single’);
layer.Bias2 = zeros([1, 1, input_channels], ‘single’);
end
function Z = forward(layer, X)
% Forward pass for training mode
% Ensure X is a dlarray
X = dlarray(X);
% Get input size
[H, W, C] = size(X);
% Global Average Pooling (GAP)
avg_pool = mean(X, [1, 2]); % Mean over height and width
avg_pool = reshape(avg_pool, [1, 1, C]); % Reshape to [1, 1, Channels]
% Global Max Pooling (GMP)
max_pool = max(X, [], [1, 2]); % Max over height and width
max_pool = reshape(max_pool, [1, 1, C]); % Reshape to [1, 1, Channels]
% First fully connected layer applied to both avg and max pooled outputs
avg_out = fullyconnect(avg_pool, layer.Weights1, layer.Bias1, C, layer.ReductionRatio);
max_out = fullyconnect(max_pool, layer.Weights1, layer.Bias1, C, layer.ReductionRatio);
% Apply ReLU
avg_out = relu(avg_out);
max_out = relu(max_out);
% Second fully connected layer
avg_out = fullyconnect(avg_out, layer.Weights2, layer.Bias2, layer.ReductionRatio, C);
max_out = fullyconnect(max_out, layer.Weights2, layer.Bias2, layer.ReductionRatio, C);
% Combine average and max pooled outputs
Z = avg_out + max_out;
% Apply sigmoid to get attention weights
Z = sigmoid(Z);
% Reshape attention map and multiply with input
Z = reshape(Z, [1, 1, C]);
Z = X .* Z;
% Ensure Z is unformatted
Z = dlarray(Z);
end
function Z = predict(layer, X)
% Predict pass for inference mode
Z = forward(layer, X);
end
end
end
% Fully connected operation for 1×1 conv
function out = fullyconnect(input, weights, bias, input_channels, output_channels)
% Ensure the number of input channels matches the weights’ channels
[H, W, C_in] = size(input);
[~, ~, C, ~] = size(weights);
if C_in ~= C
error(‘Number of channels in input and weights do not match.’);
end
% Flatten input dimensions
input_reshaped = reshape(input, [], C_in); % Flatten spatial dimensions
% Perform matrix multiplication and add bias
weights_reshaped = reshape(weights, [C_in, output_channels]);
out = input_reshaped * weights_reshaped + reshape(bias, [1, output_channels]);
% Reshape back to original dimensions
out = reshape(out, [1, 1, output_channels]);
end matlab MATLAB Answers — New Questions
Issue with Aardvark Interface in Instrument Control Toolbox
I am experiencing an issue with the Aardvark interface in the Instrument Control Toolbox. Despite having installed the Instrument Control Toolbox Support Package for Total Phase Aardvark I2C/SPI Interface, I receive the following message when attempting to use the `aardvarklist` function:
“`
Get the Aardvark driver by installing the Instrument Control Toolbox Support Package for Total Phase Aardvark I2C/SPI Interface from the Add-On Explorer.
“`
Here are the steps I have already taken to resolve the issue:
1. Reinstalled the Instrument Control Toolbox Support Package for Total Phase Aardvark I2C/SPI Interface from the Add-On Explorer.
2. Verified that the path `C:ProgramDataMATLABSupportPackagesR2024atoolboxinstrumentsupportpackagesaardvark` is included in the MATLAB path.
3. Restarted MATLAB multiple times.
4. Ensured that the Total Phase USB drivers are correctly installed and that the Aardvark adapter appears in the Windows Device Manager under the USB section.
5. Cleared the MATLAB toolbox cache using the `rehash toolboxcache` command.
6. Ran MATLAB as an administrator.
Despite these efforts, the issue persists. Could you please provide further assistance or guidance on how to resolve this problem?
Thank you for your support.I am experiencing an issue with the Aardvark interface in the Instrument Control Toolbox. Despite having installed the Instrument Control Toolbox Support Package for Total Phase Aardvark I2C/SPI Interface, I receive the following message when attempting to use the `aardvarklist` function:
“`
Get the Aardvark driver by installing the Instrument Control Toolbox Support Package for Total Phase Aardvark I2C/SPI Interface from the Add-On Explorer.
“`
Here are the steps I have already taken to resolve the issue:
1. Reinstalled the Instrument Control Toolbox Support Package for Total Phase Aardvark I2C/SPI Interface from the Add-On Explorer.
2. Verified that the path `C:ProgramDataMATLABSupportPackagesR2024atoolboxinstrumentsupportpackagesaardvark` is included in the MATLAB path.
3. Restarted MATLAB multiple times.
4. Ensured that the Total Phase USB drivers are correctly installed and that the Aardvark adapter appears in the Windows Device Manager under the USB section.
5. Cleared the MATLAB toolbox cache using the `rehash toolboxcache` command.
6. Ran MATLAB as an administrator.
Despite these efforts, the issue persists. Could you please provide further assistance or guidance on how to resolve this problem?
Thank you for your support. I am experiencing an issue with the Aardvark interface in the Instrument Control Toolbox. Despite having installed the Instrument Control Toolbox Support Package for Total Phase Aardvark I2C/SPI Interface, I receive the following message when attempting to use the `aardvarklist` function:
“`
Get the Aardvark driver by installing the Instrument Control Toolbox Support Package for Total Phase Aardvark I2C/SPI Interface from the Add-On Explorer.
“`
Here are the steps I have already taken to resolve the issue:
1. Reinstalled the Instrument Control Toolbox Support Package for Total Phase Aardvark I2C/SPI Interface from the Add-On Explorer.
2. Verified that the path `C:ProgramDataMATLABSupportPackagesR2024atoolboxinstrumentsupportpackagesaardvark` is included in the MATLAB path.
3. Restarted MATLAB multiple times.
4. Ensured that the Total Phase USB drivers are correctly installed and that the Aardvark adapter appears in the Windows Device Manager under the USB section.
5. Cleared the MATLAB toolbox cache using the `rehash toolboxcache` command.
6. Ran MATLAB as an administrator.
Despite these efforts, the issue persists. Could you please provide further assistance or guidance on how to resolve this problem?
Thank you for your support. aardvark, toolbox MATLAB Answers — New Questions
How to reduce building time in Virtual-vehicle composer
hello. I’m using Matlab 23b, and I’m using virtual vehicle composer, and I feel like changing just one constant for performance verification (for example, VCU internal thresholds) requires a full rebuild and takes a lot of time. If I run the simulation again with no changes, it starts almost immediately. Is there any way to reduce this rebuild time?hello. I’m using Matlab 23b, and I’m using virtual vehicle composer, and I feel like changing just one constant for performance verification (for example, VCU internal thresholds) requires a full rebuild and takes a lot of time. If I run the simulation again with no changes, it starts almost immediately. Is there any way to reduce this rebuild time? hello. I’m using Matlab 23b, and I’m using virtual vehicle composer, and I feel like changing just one constant for performance verification (for example, VCU internal thresholds) requires a full rebuild and takes a lot of time. If I run the simulation again with no changes, it starts almost immediately. Is there any way to reduce this rebuild time? vehicle composer, simulink MATLAB Answers — New Questions
Question regarding opticalFlowRAFT function
I am trying to use the opticalFlowRAFT function which is newly added to the 2024b version of MATLAB. However, there is very limited information regarding this function on the website. Can someone help me understand the input and output arguments of this function?
Thank youI am trying to use the opticalFlowRAFT function which is newly added to the 2024b version of MATLAB. However, there is very limited information regarding this function on the website. Can someone help me understand the input and output arguments of this function?
Thank you I am trying to use the opticalFlowRAFT function which is newly added to the 2024b version of MATLAB. However, there is very limited information regarding this function on the website. Can someone help me understand the input and output arguments of this function?
Thank you transferred MATLAB Answers — New Questions
Solve: use the Laplace transform to solve the given initial-value problem. Use a graphing utility to graph the solution. y′′ + y = 2 cos t δ(t − π) + 6 cos t δ(t − 2π), y(0) =
Solve: use the Laplace transform to solve the given
initial-value problem. Use a graphing utility to graph the
solution.
y′′ + y = 2 cos t δ(t − π) + 6 cos t δ(t − 2π), y(0) = 1, y′(0)
= 0Solve: use the Laplace transform to solve the given
initial-value problem. Use a graphing utility to graph the
solution.
y′′ + y = 2 cos t δ(t − π) + 6 cos t δ(t − 2π), y(0) = 1, y′(0)
= 0 Solve: use the Laplace transform to solve the given
initial-value problem. Use a graphing utility to graph the
solution.
y′′ + y = 2 cos t δ(t − π) + 6 cos t δ(t − 2π), y(0) = 1, y′(0)
= 0 solve: use the laplace transform to solve the give MATLAB Answers — New Questions
Problem with OFDM transmit-receive code
Hello, I have a problem with my code. It’s a basic ofdm transmitter and receiver implementation making use of BPSK. But when I increase the bps to 4 (i.e 16 QAM) and above, I don’t get the desired BER curve. I need help with this Please.
% Parameters
bps = 1; % Bits per symbol (1 for BPSK)
M = 2^bps; % Modulation order
totalBandwidth = 20e6; % Total bandwidth (Hz)
subcarrierSpacing = 15e3; % Subcarrier spacing (Hz)
nFFT = ceil(totalBandwidth / subcarrierSpacing); % Number of FFT bins
EbNoVec = 1:1:10; % Eb/No values (dB)
% Noise power values
noisePower_dBW = -120; % AWGN noise power in dBW
noisePower_W = 10^(noisePower_dBW / 10); % Convert noise power to watts
impulseNoisePower_dBW = -113; % Impulse noise power in dBW
impulseNoisePower_W = 10^(impulseNoisePower_dBW / 10); % Convert impulse noise power to watts
% Initialize BER vectors
berEstAWGN = zeros(size(EbNoVec)); % BER for AWGN only
berEstImp = zeros(size(EbNoVec)); % BER for AWGN + impulse noise
snr_dB = convertSNR(EbNoVec, "ebno", "snr", BitsPerSymbol=bps); % Convert Eb/No to SNR
% Loop over SNR values
for n = 1:length(EbNoVec)
%snr_dB = EbNoVec(n) + 10*log10(bps); % Convert Eb/No to SNR
% Initialize error and bit counters
numErrsAWGN = 0;
numErrsImp = 0;
numBits = 0;
while numErrsAWGN < 200 && numBits < 1e6
% Generate random symbols and bits
txSymbols = randi([0 M-1], nFFT, 1);
txBits = int2bit(txSymbols, bps);
% OFDM Modulation
txGrid = qammod(txSymbols, M, ‘UnitAveragePower’, true);
txOut = ifft(txGrid, nFFT);
% Calculate signal power
signalPower_dBW = snr_dB(n) + noisePower_dBW;
signalPower_W = 10^(signalPower_dBW / 10);
scalingFactor = sqrt(signalPower_W / mean(abs(txOut).^2));
txOutScaled = txOut * scalingFactor;
% AWGN
noiseSignal_notscaled = randn(size(txOutScaled)) + 1j * randn(size(txOutScaled));
noiseAWGN = sqrt(noisePower_W / 2) * noiseSignal_notscaled;
% Impulse noise (bursty)
impulseNoise = zeros(size(txOutScaled)); % Initialize as zeros
burstPositions = rand(size(txOutScaled)) < 1; % 5% of the time noise bursts occur
impulseNoise(burstPositions) = sqrt(impulseNoisePower_W / 2) * …
(randn(sum(burstPositions), 1) + 1j * randn(sum(burstPositions), 1));
% Received signal with AWGN only
rxInAWGN = txOutScaled + noiseAWGN;
% Received signal with AWGN + Impulse noise
rxInImp = txOutScaled + noiseAWGN + impulseNoise;
% OFDM Demodulation
rxGridAWGN = fft(rxInAWGN, nFFT);
rxGridImp = fft(rxInImp, nFFT);
% Demodulate symbols
rxSymbolsAWGN = qamdemod(rxGridAWGN, M, ‘UnitAveragePower’, true);
rxSymbolsImp = qamdemod(rxGridImp, M, ‘UnitAveragePower’, true);
% Convert symbols to bits
rxBitsAWGN = int2bit(rxSymbolsAWGN, bps);
rxBitsImp = int2bit(rxSymbolsImp, bps);
% Count bit errors
[bitErrorsAWGN, ~] = biterr(txBits, rxBitsAWGN);
[bitErrorsImp, ~] = biterr(txBits, rxBitsImp);
% Update error counters and transmitted bits
numErrsAWGN = numErrsAWGN + bitErrorsAWGN;
numErrsImp = numErrsImp + bitErrorsImp;
numBits = numBits + nFFT * bps;
end
% Calculate BER
berEstAWGN(n) = numErrsAWGN / numBits;
berEstImp(n) = numErrsImp / numBits;
end
% Plot BER results
figure;
semilogy(EbNoVec, berEstAWGN, ‘b-o’, ‘LineWidth’, 2); % AWGN only
hold on;
semilogy(EbNoVec, berEstImp, ‘r–o’, ‘LineWidth’, 2); % AWGN + Impulse noise
grid on;
title(‘OFDM BER for BPSK with AWGN and Impulse Noise’);
xlabel(‘Eb/No (dB)’);
ylabel(‘Bit Error Rate (BER)’);
legend(‘AWGN Only’, ‘AWGN + Impulse Noise’);
hold off;Hello, I have a problem with my code. It’s a basic ofdm transmitter and receiver implementation making use of BPSK. But when I increase the bps to 4 (i.e 16 QAM) and above, I don’t get the desired BER curve. I need help with this Please.
% Parameters
bps = 1; % Bits per symbol (1 for BPSK)
M = 2^bps; % Modulation order
totalBandwidth = 20e6; % Total bandwidth (Hz)
subcarrierSpacing = 15e3; % Subcarrier spacing (Hz)
nFFT = ceil(totalBandwidth / subcarrierSpacing); % Number of FFT bins
EbNoVec = 1:1:10; % Eb/No values (dB)
% Noise power values
noisePower_dBW = -120; % AWGN noise power in dBW
noisePower_W = 10^(noisePower_dBW / 10); % Convert noise power to watts
impulseNoisePower_dBW = -113; % Impulse noise power in dBW
impulseNoisePower_W = 10^(impulseNoisePower_dBW / 10); % Convert impulse noise power to watts
% Initialize BER vectors
berEstAWGN = zeros(size(EbNoVec)); % BER for AWGN only
berEstImp = zeros(size(EbNoVec)); % BER for AWGN + impulse noise
snr_dB = convertSNR(EbNoVec, "ebno", "snr", BitsPerSymbol=bps); % Convert Eb/No to SNR
% Loop over SNR values
for n = 1:length(EbNoVec)
%snr_dB = EbNoVec(n) + 10*log10(bps); % Convert Eb/No to SNR
% Initialize error and bit counters
numErrsAWGN = 0;
numErrsImp = 0;
numBits = 0;
while numErrsAWGN < 200 && numBits < 1e6
% Generate random symbols and bits
txSymbols = randi([0 M-1], nFFT, 1);
txBits = int2bit(txSymbols, bps);
% OFDM Modulation
txGrid = qammod(txSymbols, M, ‘UnitAveragePower’, true);
txOut = ifft(txGrid, nFFT);
% Calculate signal power
signalPower_dBW = snr_dB(n) + noisePower_dBW;
signalPower_W = 10^(signalPower_dBW / 10);
scalingFactor = sqrt(signalPower_W / mean(abs(txOut).^2));
txOutScaled = txOut * scalingFactor;
% AWGN
noiseSignal_notscaled = randn(size(txOutScaled)) + 1j * randn(size(txOutScaled));
noiseAWGN = sqrt(noisePower_W / 2) * noiseSignal_notscaled;
% Impulse noise (bursty)
impulseNoise = zeros(size(txOutScaled)); % Initialize as zeros
burstPositions = rand(size(txOutScaled)) < 1; % 5% of the time noise bursts occur
impulseNoise(burstPositions) = sqrt(impulseNoisePower_W / 2) * …
(randn(sum(burstPositions), 1) + 1j * randn(sum(burstPositions), 1));
% Received signal with AWGN only
rxInAWGN = txOutScaled + noiseAWGN;
% Received signal with AWGN + Impulse noise
rxInImp = txOutScaled + noiseAWGN + impulseNoise;
% OFDM Demodulation
rxGridAWGN = fft(rxInAWGN, nFFT);
rxGridImp = fft(rxInImp, nFFT);
% Demodulate symbols
rxSymbolsAWGN = qamdemod(rxGridAWGN, M, ‘UnitAveragePower’, true);
rxSymbolsImp = qamdemod(rxGridImp, M, ‘UnitAveragePower’, true);
% Convert symbols to bits
rxBitsAWGN = int2bit(rxSymbolsAWGN, bps);
rxBitsImp = int2bit(rxSymbolsImp, bps);
% Count bit errors
[bitErrorsAWGN, ~] = biterr(txBits, rxBitsAWGN);
[bitErrorsImp, ~] = biterr(txBits, rxBitsImp);
% Update error counters and transmitted bits
numErrsAWGN = numErrsAWGN + bitErrorsAWGN;
numErrsImp = numErrsImp + bitErrorsImp;
numBits = numBits + nFFT * bps;
end
% Calculate BER
berEstAWGN(n) = numErrsAWGN / numBits;
berEstImp(n) = numErrsImp / numBits;
end
% Plot BER results
figure;
semilogy(EbNoVec, berEstAWGN, ‘b-o’, ‘LineWidth’, 2); % AWGN only
hold on;
semilogy(EbNoVec, berEstImp, ‘r–o’, ‘LineWidth’, 2); % AWGN + Impulse noise
grid on;
title(‘OFDM BER for BPSK with AWGN and Impulse Noise’);
xlabel(‘Eb/No (dB)’);
ylabel(‘Bit Error Rate (BER)’);
legend(‘AWGN Only’, ‘AWGN + Impulse Noise’);
hold off; Hello, I have a problem with my code. It’s a basic ofdm transmitter and receiver implementation making use of BPSK. But when I increase the bps to 4 (i.e 16 QAM) and above, I don’t get the desired BER curve. I need help with this Please.
% Parameters
bps = 1; % Bits per symbol (1 for BPSK)
M = 2^bps; % Modulation order
totalBandwidth = 20e6; % Total bandwidth (Hz)
subcarrierSpacing = 15e3; % Subcarrier spacing (Hz)
nFFT = ceil(totalBandwidth / subcarrierSpacing); % Number of FFT bins
EbNoVec = 1:1:10; % Eb/No values (dB)
% Noise power values
noisePower_dBW = -120; % AWGN noise power in dBW
noisePower_W = 10^(noisePower_dBW / 10); % Convert noise power to watts
impulseNoisePower_dBW = -113; % Impulse noise power in dBW
impulseNoisePower_W = 10^(impulseNoisePower_dBW / 10); % Convert impulse noise power to watts
% Initialize BER vectors
berEstAWGN = zeros(size(EbNoVec)); % BER for AWGN only
berEstImp = zeros(size(EbNoVec)); % BER for AWGN + impulse noise
snr_dB = convertSNR(EbNoVec, "ebno", "snr", BitsPerSymbol=bps); % Convert Eb/No to SNR
% Loop over SNR values
for n = 1:length(EbNoVec)
%snr_dB = EbNoVec(n) + 10*log10(bps); % Convert Eb/No to SNR
% Initialize error and bit counters
numErrsAWGN = 0;
numErrsImp = 0;
numBits = 0;
while numErrsAWGN < 200 && numBits < 1e6
% Generate random symbols and bits
txSymbols = randi([0 M-1], nFFT, 1);
txBits = int2bit(txSymbols, bps);
% OFDM Modulation
txGrid = qammod(txSymbols, M, ‘UnitAveragePower’, true);
txOut = ifft(txGrid, nFFT);
% Calculate signal power
signalPower_dBW = snr_dB(n) + noisePower_dBW;
signalPower_W = 10^(signalPower_dBW / 10);
scalingFactor = sqrt(signalPower_W / mean(abs(txOut).^2));
txOutScaled = txOut * scalingFactor;
% AWGN
noiseSignal_notscaled = randn(size(txOutScaled)) + 1j * randn(size(txOutScaled));
noiseAWGN = sqrt(noisePower_W / 2) * noiseSignal_notscaled;
% Impulse noise (bursty)
impulseNoise = zeros(size(txOutScaled)); % Initialize as zeros
burstPositions = rand(size(txOutScaled)) < 1; % 5% of the time noise bursts occur
impulseNoise(burstPositions) = sqrt(impulseNoisePower_W / 2) * …
(randn(sum(burstPositions), 1) + 1j * randn(sum(burstPositions), 1));
% Received signal with AWGN only
rxInAWGN = txOutScaled + noiseAWGN;
% Received signal with AWGN + Impulse noise
rxInImp = txOutScaled + noiseAWGN + impulseNoise;
% OFDM Demodulation
rxGridAWGN = fft(rxInAWGN, nFFT);
rxGridImp = fft(rxInImp, nFFT);
% Demodulate symbols
rxSymbolsAWGN = qamdemod(rxGridAWGN, M, ‘UnitAveragePower’, true);
rxSymbolsImp = qamdemod(rxGridImp, M, ‘UnitAveragePower’, true);
% Convert symbols to bits
rxBitsAWGN = int2bit(rxSymbolsAWGN, bps);
rxBitsImp = int2bit(rxSymbolsImp, bps);
% Count bit errors
[bitErrorsAWGN, ~] = biterr(txBits, rxBitsAWGN);
[bitErrorsImp, ~] = biterr(txBits, rxBitsImp);
% Update error counters and transmitted bits
numErrsAWGN = numErrsAWGN + bitErrorsAWGN;
numErrsImp = numErrsImp + bitErrorsImp;
numBits = numBits + nFFT * bps;
end
% Calculate BER
berEstAWGN(n) = numErrsAWGN / numBits;
berEstImp(n) = numErrsImp / numBits;
end
% Plot BER results
figure;
semilogy(EbNoVec, berEstAWGN, ‘b-o’, ‘LineWidth’, 2); % AWGN only
hold on;
semilogy(EbNoVec, berEstImp, ‘r–o’, ‘LineWidth’, 2); % AWGN + Impulse noise
grid on;
title(‘OFDM BER for BPSK with AWGN and Impulse Noise’);
xlabel(‘Eb/No (dB)’);
ylabel(‘Bit Error Rate (BER)’);
legend(‘AWGN Only’, ‘AWGN + Impulse Noise’);
hold off; ofdm MATLAB Answers — New Questions
How to visualize a vector in Simscape Multibody
Hello!
I have been working on a 6-DOF Simscape Multibody simulation for a thrust vectored rocket. The simulation works, but I have been wanting to visualize the thrust vector below the rocket. How should I go about this?
In my searching, I have found that this visualization would likely have to be a geometric solid with no mass, which is okay (I just want an indication of direction and I have modeled a vector solid already). This would be relatively straightforward if the Rigid Transform block could take a dynamic rotation matrix, as that is already what my simulation uses to calculate the thrust vector in the proper global frame, but it seems that it can only take a compile- or run-time rotation matrix.
I have also considered using a spherical joint under the rocket connected to the vector solid, but doing so would require being able to set the position of the spherical joint, and I have not been able to figure out how to do that.
I have even tried making my own Simscape component to act as a Dynamic Transform block, but the Simscape language does not have access to the Multibody Frame class necessary to make this work.
Is visualizing a vector like this possible, and if so, what is the best way to go about it?Hello!
I have been working on a 6-DOF Simscape Multibody simulation for a thrust vectored rocket. The simulation works, but I have been wanting to visualize the thrust vector below the rocket. How should I go about this?
In my searching, I have found that this visualization would likely have to be a geometric solid with no mass, which is okay (I just want an indication of direction and I have modeled a vector solid already). This would be relatively straightforward if the Rigid Transform block could take a dynamic rotation matrix, as that is already what my simulation uses to calculate the thrust vector in the proper global frame, but it seems that it can only take a compile- or run-time rotation matrix.
I have also considered using a spherical joint under the rocket connected to the vector solid, but doing so would require being able to set the position of the spherical joint, and I have not been able to figure out how to do that.
I have even tried making my own Simscape component to act as a Dynamic Transform block, but the Simscape language does not have access to the Multibody Frame class necessary to make this work.
Is visualizing a vector like this possible, and if so, what is the best way to go about it? Hello!
I have been working on a 6-DOF Simscape Multibody simulation for a thrust vectored rocket. The simulation works, but I have been wanting to visualize the thrust vector below the rocket. How should I go about this?
In my searching, I have found that this visualization would likely have to be a geometric solid with no mass, which is okay (I just want an indication of direction and I have modeled a vector solid already). This would be relatively straightforward if the Rigid Transform block could take a dynamic rotation matrix, as that is already what my simulation uses to calculate the thrust vector in the proper global frame, but it seems that it can only take a compile- or run-time rotation matrix.
I have also considered using a spherical joint under the rocket connected to the vector solid, but doing so would require being able to set the position of the spherical joint, and I have not been able to figure out how to do that.
I have even tried making my own Simscape component to act as a Dynamic Transform block, but the Simscape language does not have access to the Multibody Frame class necessary to make this work.
Is visualizing a vector like this possible, and if so, what is the best way to go about it? simscape, simulink MATLAB Answers — New Questions
I am getting errors that I am using “.*” and “*” wrongly in my matrix multiplications in my code. I am poor at matrix algebra and don’t know when to use each operator.
I am getting errors that I am using ".*" and "*" wrongly in my matrix multiplications in my code. I am poor at matrix algebra and don’t know when to use each operator.
clear;
clc;
H=[5, -5;
2.5, -2.5;
0, -2.5;
0, -4;
-4, -2.5]
diagW=diag([1, 1, 1, 1, 1]*10^4);
Z=[0.85;
0.8;
0.6;
0.4;
-0.81]
transH=H’;
%Ht=transpose of H;
HtWH=transH*diagW.*H;
HtWZ=transH*diagW.*Z;
X=(inv(HtWH)).*HtWZ;
Zhat=Z.*X;
%Estimation of errors.
ESTofErrors=Z-Zhat;
%Value of the cost function
variance=[0.015, 0.01, 0.005, 0.015, 0.01]
CF=0;
for i=1:5
CF = CF + ((Zhat(i))^2/(variance(i))^2)
end
alpha=0.01;
K=3;
Xka=chi2cdf(0.1, 3);
Xka=11.345;
G=HtWH;
invG=inv(G);
HinvGHt=H.*invG.*Ht;
R=ESTofErrors;
S=R-(H*invG.*transH);
diagS=diag(S);
%Expected value of the cost function.
EVCF=sum(diagS,2);
%Calculating the standardized error
SE=(variance)/sqrt(5);
Errors: Arrays have incompatible sizes for this operation.I am getting errors that I am using ".*" and "*" wrongly in my matrix multiplications in my code. I am poor at matrix algebra and don’t know when to use each operator.
clear;
clc;
H=[5, -5;
2.5, -2.5;
0, -2.5;
0, -4;
-4, -2.5]
diagW=diag([1, 1, 1, 1, 1]*10^4);
Z=[0.85;
0.8;
0.6;
0.4;
-0.81]
transH=H’;
%Ht=transpose of H;
HtWH=transH*diagW.*H;
HtWZ=transH*diagW.*Z;
X=(inv(HtWH)).*HtWZ;
Zhat=Z.*X;
%Estimation of errors.
ESTofErrors=Z-Zhat;
%Value of the cost function
variance=[0.015, 0.01, 0.005, 0.015, 0.01]
CF=0;
for i=1:5
CF = CF + ((Zhat(i))^2/(variance(i))^2)
end
alpha=0.01;
K=3;
Xka=chi2cdf(0.1, 3);
Xka=11.345;
G=HtWH;
invG=inv(G);
HinvGHt=H.*invG.*Ht;
R=ESTofErrors;
S=R-(H*invG.*transH);
diagS=diag(S);
%Expected value of the cost function.
EVCF=sum(diagS,2);
%Calculating the standardized error
SE=(variance)/sqrt(5);
Errors: Arrays have incompatible sizes for this operation. I am getting errors that I am using ".*" and "*" wrongly in my matrix multiplications in my code. I am poor at matrix algebra and don’t know when to use each operator.
clear;
clc;
H=[5, -5;
2.5, -2.5;
0, -2.5;
0, -4;
-4, -2.5]
diagW=diag([1, 1, 1, 1, 1]*10^4);
Z=[0.85;
0.8;
0.6;
0.4;
-0.81]
transH=H’;
%Ht=transpose of H;
HtWH=transH*diagW.*H;
HtWZ=transH*diagW.*Z;
X=(inv(HtWH)).*HtWZ;
Zhat=Z.*X;
%Estimation of errors.
ESTofErrors=Z-Zhat;
%Value of the cost function
variance=[0.015, 0.01, 0.005, 0.015, 0.01]
CF=0;
for i=1:5
CF = CF + ((Zhat(i))^2/(variance(i))^2)
end
alpha=0.01;
K=3;
Xka=chi2cdf(0.1, 3);
Xka=11.345;
G=HtWH;
invG=inv(G);
HinvGHt=H.*invG.*Ht;
R=ESTofErrors;
S=R-(H*invG.*transH);
diagS=diag(S);
%Expected value of the cost function.
EVCF=sum(diagS,2);
%Calculating the standardized error
SE=(variance)/sqrt(5);
Errors: Arrays have incompatible sizes for this operation. matrix multiplication, matrix algebra MATLAB Answers — New Questions
Why do I get a connection error when installing or activating MATLAB or other MathWorks products?
I get an error that I cannot connect to MathWorks when running the MathWorks installer or the activation client; however, I can access the website. Why can’t the MathWorks Installer or activation client connect to the MathWorks?
Connection Error
The application could not connect to MathWorks.
For more information on resolving this issue, see this Support Article.I get an error that I cannot connect to MathWorks when running the MathWorks installer or the activation client; however, I can access the website. Why can’t the MathWorks Installer or activation client connect to the MathWorks?
Connection Error
The application could not connect to MathWorks.
For more information on resolving this issue, see this Support Article. I get an error that I cannot connect to MathWorks when running the MathWorks installer or the activation client; however, I can access the website. Why can’t the MathWorks Installer or activation client connect to the MathWorks?
Connection Error
The application could not connect to MathWorks.
For more information on resolving this issue, see this Support Article. MATLAB Answers — New Questions
How do I plot an integral which is repeated over an interval?
I am attempting to plot the absporptance (alpha_s_bar) of an uncontaminated spacecraft as a function of the incident light wavelenght. The absorptance is found by integrating two different functions of wavelength over an interval from zero to the wavelength value of interest, on an interval from 0 to 0.7 microns. The code I have attached below runs and returns different values of absorptance as the wavelenght of interest (L) changes, but does not save the values before iterating, so I end up with one scalar value as alpha_s_bar. I am interested in saving the values of alpha_s_bar as a vector so I can plot them against the wavelength.
%Note that I will be using x for the wavelength for ease of typing
% Start by defining the constants for the absorptance for typical
% outgassing products, called alpha_c in problem statement, where
% alpha_c=M10*exp(M11*L)
M10=34.898;
M11=-8.6481;
% Next define the constants for solar absorptivity, alpha_s, where
% aplha_s=M0+M1*L+M2*L^2+M3*L^3
M0=0.28779;
M1=0.06028;
M2=-0.046055;
M3=0.020211;
% Next, define the constants for the solar spectrum (adjusted so units are microns), S, where
% S=2*C1/L^5[exp(C2/L*T)-1]
T=5500;
C1=5.594E-7;
C2=1438.8;
for L=0:0.01:0.7;
fnum=@(x) (M0+M1.*x+M2.*(x.^2)+M3.*(x.^3))./((x.^5).*exp(C2./(x.*T)));
fden=@(x) 1./((x.^5).*exp(C2./(x.*T)));
alpha_bar_s=integral(fnum,0,L)./integral(fden,0,L)
plot(L,alpha_bar_s)
hold on
endI am attempting to plot the absporptance (alpha_s_bar) of an uncontaminated spacecraft as a function of the incident light wavelenght. The absorptance is found by integrating two different functions of wavelength over an interval from zero to the wavelength value of interest, on an interval from 0 to 0.7 microns. The code I have attached below runs and returns different values of absorptance as the wavelenght of interest (L) changes, but does not save the values before iterating, so I end up with one scalar value as alpha_s_bar. I am interested in saving the values of alpha_s_bar as a vector so I can plot them against the wavelength.
%Note that I will be using x for the wavelength for ease of typing
% Start by defining the constants for the absorptance for typical
% outgassing products, called alpha_c in problem statement, where
% alpha_c=M10*exp(M11*L)
M10=34.898;
M11=-8.6481;
% Next define the constants for solar absorptivity, alpha_s, where
% aplha_s=M0+M1*L+M2*L^2+M3*L^3
M0=0.28779;
M1=0.06028;
M2=-0.046055;
M3=0.020211;
% Next, define the constants for the solar spectrum (adjusted so units are microns), S, where
% S=2*C1/L^5[exp(C2/L*T)-1]
T=5500;
C1=5.594E-7;
C2=1438.8;
for L=0:0.01:0.7;
fnum=@(x) (M0+M1.*x+M2.*(x.^2)+M3.*(x.^3))./((x.^5).*exp(C2./(x.*T)));
fden=@(x) 1./((x.^5).*exp(C2./(x.*T)));
alpha_bar_s=integral(fnum,0,L)./integral(fden,0,L)
plot(L,alpha_bar_s)
hold on
end I am attempting to plot the absporptance (alpha_s_bar) of an uncontaminated spacecraft as a function of the incident light wavelenght. The absorptance is found by integrating two different functions of wavelength over an interval from zero to the wavelength value of interest, on an interval from 0 to 0.7 microns. The code I have attached below runs and returns different values of absorptance as the wavelenght of interest (L) changes, but does not save the values before iterating, so I end up with one scalar value as alpha_s_bar. I am interested in saving the values of alpha_s_bar as a vector so I can plot them against the wavelength.
%Note that I will be using x for the wavelength for ease of typing
% Start by defining the constants for the absorptance for typical
% outgassing products, called alpha_c in problem statement, where
% alpha_c=M10*exp(M11*L)
M10=34.898;
M11=-8.6481;
% Next define the constants for solar absorptivity, alpha_s, where
% aplha_s=M0+M1*L+M2*L^2+M3*L^3
M0=0.28779;
M1=0.06028;
M2=-0.046055;
M3=0.020211;
% Next, define the constants for the solar spectrum (adjusted so units are microns), S, where
% S=2*C1/L^5[exp(C2/L*T)-1]
T=5500;
C1=5.594E-7;
C2=1438.8;
for L=0:0.01:0.7;
fnum=@(x) (M0+M1.*x+M2.*(x.^2)+M3.*(x.^3))./((x.^5).*exp(C2./(x.*T)));
fden=@(x) 1./((x.^5).*exp(C2./(x.*T)));
alpha_bar_s=integral(fnum,0,L)./integral(fden,0,L)
plot(L,alpha_bar_s)
hold on
end matlab, integral, plotting, for loop MATLAB Answers — New Questions
Does MATLAB support High DPI screens on Linux?
I am running MATLAB on Linux on a high resolution 4K display. The menus, menu bar, etc are very small and the characters are difficult to read because of their small size. I have already changed the font size in the editor and command window, but I cannot find any way of changing the MATLAB program menu bar size. I am running MATLAB on Linux on a high resolution 4K display. The menus, menu bar, etc are very small and the characters are difficult to read because of their small size. I have already changed the font size in the editor and command window, but I cannot find any way of changing the MATLAB program menu bar size. I am running MATLAB on Linux on a high resolution 4K display. The menus, menu bar, etc are very small and the characters are difficult to read because of their small size. I have already changed the font size in the editor and command window, but I cannot find any way of changing the MATLAB program menu bar size. high, dpi, ubuntu, linux, 4k MATLAB Answers — New Questions
Reference data source for Simulink Data center cooling example’s default values
I am looking for the source for the default numbers that are used in Data center cooling example of Simulink.
Is there any source for it?I am looking for the source for the default numbers that are used in Data center cooling example of Simulink.
Is there any source for it? I am looking for the source for the default numbers that are used in Data center cooling example of Simulink.
Is there any source for it? simulnk, simscape MATLAB Answers — New Questions
load-sensitive system in simscape
I am building a model of a load-sensitive system in simscape. I used a pressure compensator to control the pressure drop before and after the valve, but this compensator does not seem to be able to adjust the opening area based on the feedback. The area can only be calculated based on the pressure drop. Refer to Figure 1. This problem bothers me.
Figure 1I am building a model of a load-sensitive system in simscape. I used a pressure compensator to control the pressure drop before and after the valve, but this compensator does not seem to be able to adjust the opening area based on the feedback. The area can only be calculated based on the pressure drop. Refer to Figure 1. This problem bothers me.
Figure 1 I am building a model of a load-sensitive system in simscape. I used a pressure compensator to control the pressure drop before and after the valve, but this compensator does not seem to be able to adjust the opening area based on the feedback. The area can only be calculated based on the pressure drop. Refer to Figure 1. This problem bothers me.
Figure 1 simscape, hydraulic system MATLAB Answers — New Questions
Error regarding jxbrower DLL when opening Live Editor Script
A customer is getting the below error and also MATLAB freezes everytime they try to open Live Editor files:
Exception in thread "IPC Process Thread" java.lang.UnsatisfiedLinkError: C:UsersxxxxAppDataLocalTemp1jxbrowser-chromium-43.0.2357.52.5.4.3dataTempjxbrowser-common64-7f5a758a-e611-4dcb-b8ce-ecd0c96bb9a2.dll: This program is blocked by group policy. For more information, contact your system administrator at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824) at java.lang.Runtime.load0(Runtime.java:809) at java.lang.System.load(System.java:1086) at com.teamdev.jxbrowser.chromium.internal.LibraryLoader.loadLibrary(Unknown Source) at com.teamdev.jxbrowser.chromium.internal.SharedMemoryLibrary.<init>(Unknown Source) at com.teamdev.jxbrowser.chromium.internal.SharedMemoryLibrary.getInstance(Unknown Source) at com.teamdev.jxbrowser.chromium.internal.ipc.ChromiumProcess.start(Unknown Source) at com.teamdev.jxbrowser.chromium.internal.ipc.d.run(Unknown Source) at java.lang.Thread.run(Thread.java:748)
Customer could run the file but not open it or edit it or see the code. They were also able to run M file. the issue was only with Live Script.A customer is getting the below error and also MATLAB freezes everytime they try to open Live Editor files:
Exception in thread "IPC Process Thread" java.lang.UnsatisfiedLinkError: C:UsersxxxxAppDataLocalTemp1jxbrowser-chromium-43.0.2357.52.5.4.3dataTempjxbrowser-common64-7f5a758a-e611-4dcb-b8ce-ecd0c96bb9a2.dll: This program is blocked by group policy. For more information, contact your system administrator at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824) at java.lang.Runtime.load0(Runtime.java:809) at java.lang.System.load(System.java:1086) at com.teamdev.jxbrowser.chromium.internal.LibraryLoader.loadLibrary(Unknown Source) at com.teamdev.jxbrowser.chromium.internal.SharedMemoryLibrary.<init>(Unknown Source) at com.teamdev.jxbrowser.chromium.internal.SharedMemoryLibrary.getInstance(Unknown Source) at com.teamdev.jxbrowser.chromium.internal.ipc.ChromiumProcess.start(Unknown Source) at com.teamdev.jxbrowser.chromium.internal.ipc.d.run(Unknown Source) at java.lang.Thread.run(Thread.java:748)
Customer could run the file but not open it or edit it or see the code. They were also able to run M file. the issue was only with Live Script. A customer is getting the below error and also MATLAB freezes everytime they try to open Live Editor files:
Exception in thread "IPC Process Thread" java.lang.UnsatisfiedLinkError: C:UsersxxxxAppDataLocalTemp1jxbrowser-chromium-43.0.2357.52.5.4.3dataTempjxbrowser-common64-7f5a758a-e611-4dcb-b8ce-ecd0c96bb9a2.dll: This program is blocked by group policy. For more information, contact your system administrator at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824) at java.lang.Runtime.load0(Runtime.java:809) at java.lang.System.load(System.java:1086) at com.teamdev.jxbrowser.chromium.internal.LibraryLoader.loadLibrary(Unknown Source) at com.teamdev.jxbrowser.chromium.internal.SharedMemoryLibrary.<init>(Unknown Source) at com.teamdev.jxbrowser.chromium.internal.SharedMemoryLibrary.getInstance(Unknown Source) at com.teamdev.jxbrowser.chromium.internal.ipc.ChromiumProcess.start(Unknown Source) at com.teamdev.jxbrowser.chromium.internal.ipc.d.run(Unknown Source) at java.lang.Thread.run(Thread.java:748)
Customer could run the file but not open it or edit it or see the code. They were also able to run M file. the issue was only with Live Script. live, editor, group, policy, blocked, ipc, process, thread MATLAB Answers — New Questions
forward Euler function to solve ODEs
according to the assignment I’m working on, i have to
(a) Set (tstart, tfinal, y0, f, nsteps) to be the inputs and an output vector yvec. i. tstart is the starting time ii. tfinal is the final time. iii. f is an anonymous function handle that defines the right hand side of whatever ODE we’re studying. iv. y0 is the initial condition for the given ODE v. nsteps is the number of timesteps you’re taking. vi. name the function forward_euler
(b) Define a stepsize dt using tstart, tfinal and nsteps. Then use these to construct a discretized time domain vector tvec.
(c) Set t(1) = tstart and y(1) = y0.
(d) Construct a for-loop that performs the Forward Euler algorithm that was discussed in class.
(e) (Optional but super helpful for plotting): Instead of returning only yvec, you could return [tvec, yvec]Question 2.1according to the assignment I’m working on, i have to
(a) Set (tstart, tfinal, y0, f, nsteps) to be the inputs and an output vector yvec. i. tstart is the starting time ii. tfinal is the final time. iii. f is an anonymous function handle that defines the right hand side of whatever ODE we’re studying. iv. y0 is the initial condition for the given ODE v. nsteps is the number of timesteps you’re taking. vi. name the function forward_euler
(b) Define a stepsize dt using tstart, tfinal and nsteps. Then use these to construct a discretized time domain vector tvec.
(c) Set t(1) = tstart and y(1) = y0.
(d) Construct a for-loop that performs the Forward Euler algorithm that was discussed in class.
(e) (Optional but super helpful for plotting): Instead of returning only yvec, you could return [tvec, yvec]Question 2.1 according to the assignment I’m working on, i have to
(a) Set (tstart, tfinal, y0, f, nsteps) to be the inputs and an output vector yvec. i. tstart is the starting time ii. tfinal is the final time. iii. f is an anonymous function handle that defines the right hand side of whatever ODE we’re studying. iv. y0 is the initial condition for the given ODE v. nsteps is the number of timesteps you’re taking. vi. name the function forward_euler
(b) Define a stepsize dt using tstart, tfinal and nsteps. Then use these to construct a discretized time domain vector tvec.
(c) Set t(1) = tstart and y(1) = y0.
(d) Construct a for-loop that performs the Forward Euler algorithm that was discussed in class.
(e) (Optional but super helpful for plotting): Instead of returning only yvec, you could return [tvec, yvec]Question 2.1 for loop, function, vectors MATLAB Answers — New Questions
difference between dissect in matlab and METIS_NodeND in Metis?
Hello everyone,
I find that dissect in matlab utilize the METIS library, and it can choose the number of separator, which is also the number of subdomain.
But it seems like that there is no choice of the number of separator in the interface METIS_NodeND in METIS.
So what is the difference between the dissect and METIS_NodeND?Hello everyone,
I find that dissect in matlab utilize the METIS library, and it can choose the number of separator, which is also the number of subdomain.
But it seems like that there is no choice of the number of separator in the interface METIS_NodeND in METIS.
So what is the difference between the dissect and METIS_NodeND? Hello everyone,
I find that dissect in matlab utilize the METIS library, and it can choose the number of separator, which is also the number of subdomain.
But it seems like that there is no choice of the number of separator in the interface METIS_NodeND in METIS.
So what is the difference between the dissect and METIS_NodeND? metis, dissect MATLAB Answers — New Questions