Category: Matlab
Category Archives: Matlab
How to draw a graph like the image attached below in MATLAB
Hello, experts.
I would like to draw the picture below using Matlab. What function can I use to plot it?Hello, experts.
I would like to draw the picture below using Matlab. What function can I use to plot it? Hello, experts.
I would like to draw the picture below using Matlab. What function can I use to plot it? graph, plot MATLAB Answers — New Questions
Copying a figure with black background not working
I want to copy and paste my figure onto ppt.
I have made a figure using black background
This is what it looks like in open figure window:
However if I directly copy and paste it to ppt from the edit menu, it looks like this:
When I save it as jpg, this is what it looks like:
How to solve this issue?
Part of the code: (I am not sure if the way to make the background as black is the issue)
fig = figure;
fig.Color = ‘k’; % figure background color black
tiledlayout(1, (num_days), ‘TileSpacing’, ‘compact’, ‘Padding’, ‘compact’);
% code to generate figure
ax = nexttile; % made it as I have to change the axis to white and background to black
% Set the axes background color to black
ax.Color = ‘k’; % sets the axes color to black
% Adjust the colors for axes and grid to be more visible against the black background
ax.XColor = ‘w’; % sets the x-axis line color to white
ax.YColor = ‘w’; % sets the y-axis line color to white
ax.GridColor = ‘w’; % sets the grid lines color to white (if visible grid is present)I want to copy and paste my figure onto ppt.
I have made a figure using black background
This is what it looks like in open figure window:
However if I directly copy and paste it to ppt from the edit menu, it looks like this:
When I save it as jpg, this is what it looks like:
How to solve this issue?
Part of the code: (I am not sure if the way to make the background as black is the issue)
fig = figure;
fig.Color = ‘k’; % figure background color black
tiledlayout(1, (num_days), ‘TileSpacing’, ‘compact’, ‘Padding’, ‘compact’);
% code to generate figure
ax = nexttile; % made it as I have to change the axis to white and background to black
% Set the axes background color to black
ax.Color = ‘k’; % sets the axes color to black
% Adjust the colors for axes and grid to be more visible against the black background
ax.XColor = ‘w’; % sets the x-axis line color to white
ax.YColor = ‘w’; % sets the y-axis line color to white
ax.GridColor = ‘w’; % sets the grid lines color to white (if visible grid is present) I want to copy and paste my figure onto ppt.
I have made a figure using black background
This is what it looks like in open figure window:
However if I directly copy and paste it to ppt from the edit menu, it looks like this:
When I save it as jpg, this is what it looks like:
How to solve this issue?
Part of the code: (I am not sure if the way to make the background as black is the issue)
fig = figure;
fig.Color = ‘k’; % figure background color black
tiledlayout(1, (num_days), ‘TileSpacing’, ‘compact’, ‘Padding’, ‘compact’);
% code to generate figure
ax = nexttile; % made it as I have to change the axis to white and background to black
% Set the axes background color to black
ax.Color = ‘k’; % sets the axes color to black
% Adjust the colors for axes and grid to be more visible against the black background
ax.XColor = ‘w’; % sets the x-axis line color to white
ax.YColor = ‘w’; % sets the y-axis line color to white
ax.GridColor = ‘w’; % sets the grid lines color to white (if visible grid is present) figure, copy MATLAB Answers — New Questions
connect variable signals with signal builder or equivalent block using M Script
I have a .mat file that contains various signals and their corresponding values. I also have a model file that contains similar signal names in inport blocks, which are connected to a subsystem. However, the values of these signals in the model file differ from the values in the .mat file.My task is to match the signals of the inport blocks to the signals in the .mat file. If a signal is present in both files, I need to assign the .mat signal and its value to the corresponding inport block in the model. Instead of using the inport block, I need to use a Signal Builder block (or a similar block that I’m not currently aware of).The reason for using a Signal Builder block is that it allows me to assign both the signal value and time to the block. This way, I can directly test the model by running it.In the input files, I will provide:
A model file containing inport blocks
A .mat file
I will write a script that compares the signals in the model file with the signals in the .mat file. If any signals in the model file match the signals in the .mat file, the script will assign the .mat signal values to the corresponding Signal Builder blocks in the model.After making these changes, I will store the updated model file separately without modifying the original model file. it is possible to perform this task and how ?I have a .mat file that contains various signals and their corresponding values. I also have a model file that contains similar signal names in inport blocks, which are connected to a subsystem. However, the values of these signals in the model file differ from the values in the .mat file.My task is to match the signals of the inport blocks to the signals in the .mat file. If a signal is present in both files, I need to assign the .mat signal and its value to the corresponding inport block in the model. Instead of using the inport block, I need to use a Signal Builder block (or a similar block that I’m not currently aware of).The reason for using a Signal Builder block is that it allows me to assign both the signal value and time to the block. This way, I can directly test the model by running it.In the input files, I will provide:
A model file containing inport blocks
A .mat file
I will write a script that compares the signals in the model file with the signals in the .mat file. If any signals in the model file match the signals in the .mat file, the script will assign the .mat signal values to the corresponding Signal Builder blocks in the model.After making these changes, I will store the updated model file separately without modifying the original model file. it is possible to perform this task and how ? I have a .mat file that contains various signals and their corresponding values. I also have a model file that contains similar signal names in inport blocks, which are connected to a subsystem. However, the values of these signals in the model file differ from the values in the .mat file.My task is to match the signals of the inport blocks to the signals in the .mat file. If a signal is present in both files, I need to assign the .mat signal and its value to the corresponding inport block in the model. Instead of using the inport block, I need to use a Signal Builder block (or a similar block that I’m not currently aware of).The reason for using a Signal Builder block is that it allows me to assign both the signal value and time to the block. This way, I can directly test the model by running it.In the input files, I will provide:
A model file containing inport blocks
A .mat file
I will write a script that compares the signals in the model file with the signals in the .mat file. If any signals in the model file match the signals in the .mat file, the script will assign the .mat signal values to the corresponding Signal Builder blocks in the model.After making these changes, I will store the updated model file separately without modifying the original model file. it is possible to perform this task and how ? #mscript #signalbuilder #matfile #modeldataextract MATLAB Answers — New Questions
summations of combinations of elements, one from each column of a 2D matrix, in small to large order
I have a 2D numerical matrix of size 1000 by 8: [0 a1 a2 a3 a4 … a999; 0 b1 b2 b3 b4 … b999; … ; 0 h1 h2 h3 h4 … h999]’ , where each column is in ascending order, i.e., 0<a1<a2<a3<…<a999, etc. However, I don’t know how a1 compares to b1, or c1, etc. For example, b100 could be smaller than a1.
Now, I would like to find the first 1000,000 combinations of 8 elements, each coming from a column, that have the smallest summation values. For each combination, I would like to retain the row and column indices of each element as well.
Can anyone help me with the problem? Thank you very much for your help in advance.I have a 2D numerical matrix of size 1000 by 8: [0 a1 a2 a3 a4 … a999; 0 b1 b2 b3 b4 … b999; … ; 0 h1 h2 h3 h4 … h999]’ , where each column is in ascending order, i.e., 0<a1<a2<a3<…<a999, etc. However, I don’t know how a1 compares to b1, or c1, etc. For example, b100 could be smaller than a1.
Now, I would like to find the first 1000,000 combinations of 8 elements, each coming from a column, that have the smallest summation values. For each combination, I would like to retain the row and column indices of each element as well.
Can anyone help me with the problem? Thank you very much for your help in advance. I have a 2D numerical matrix of size 1000 by 8: [0 a1 a2 a3 a4 … a999; 0 b1 b2 b3 b4 … b999; … ; 0 h1 h2 h3 h4 … h999]’ , where each column is in ascending order, i.e., 0<a1<a2<a3<…<a999, etc. However, I don’t know how a1 compares to b1, or c1, etc. For example, b100 could be smaller than a1.
Now, I would like to find the first 1000,000 combinations of 8 elements, each coming from a column, that have the smallest summation values. For each combination, I would like to retain the row and column indices of each element as well.
Can anyone help me with the problem? Thank you very much for your help in advance. combinations, summation, order MATLAB Answers — New Questions
ROS 2 Dashing and Gazebo
Hi,
I am doing the installation of the ROS 2 Dashing and Gazebo as seen here
I am wokring on windows and have the VM installed and sucessfully have the ros_melodic_dashing_gazebov9.vmx operating.
When trying to use the worlds on my desktop, they simply open a terminal windows for a split second and then close again. It seems that they crash or Gazebo runs into issues and fails to open any of the worlds.
I have also tried this in conjunciton with the differetial drive example here . Which indicates to use
export SVGA_VGPU10=0
before opening the world, however this does not work either.
Any suggestions as to what is the problem?
Thanks,
RobHi,
I am doing the installation of the ROS 2 Dashing and Gazebo as seen here
I am wokring on windows and have the VM installed and sucessfully have the ros_melodic_dashing_gazebov9.vmx operating.
When trying to use the worlds on my desktop, they simply open a terminal windows for a split second and then close again. It seems that they crash or Gazebo runs into issues and fails to open any of the worlds.
I have also tried this in conjunciton with the differetial drive example here . Which indicates to use
export SVGA_VGPU10=0
before opening the world, however this does not work either.
Any suggestions as to what is the problem?
Thanks,
Rob Hi,
I am doing the installation of the ROS 2 Dashing and Gazebo as seen here
I am wokring on windows and have the VM installed and sucessfully have the ros_melodic_dashing_gazebov9.vmx operating.
When trying to use the worlds on my desktop, they simply open a terminal windows for a split second and then close again. It seems that they crash or Gazebo runs into issues and fails to open any of the worlds.
I have also tried this in conjunciton with the differetial drive example here . Which indicates to use
export SVGA_VGPU10=0
before opening the world, however this does not work either.
Any suggestions as to what is the problem?
Thanks,
Rob matlab, ros, gazebo, dashing, ros 2, vm, crashing MATLAB Answers — New Questions
Can’t dewarp image using fitgeotform2d and imwarp
I’m trying to reverse a transformation in an image. I have point coordinates in the intrinsic coordinate (moving points) and their equivalent in the real world coordinates (fixed points). When I use the fitgeotform2d and imwarp functions to obtained a dewarped image, I only get an matrix of zeros and size of the original image as output. Here’s the data and the code:
load("calImg.mat")
J = double(calImg);
fixedPoints = W;
movingPoints = I;
figure(1)
imagesc(J)
tform = fitgeotform2d(movingPoints,fixedPoints,"projective");
Jregistered = imwarp(flipud(J),tform,OutputView=imref2d(size(J)));
figure(2)
imshowpair(I,Jregistered)I’m trying to reverse a transformation in an image. I have point coordinates in the intrinsic coordinate (moving points) and their equivalent in the real world coordinates (fixed points). When I use the fitgeotform2d and imwarp functions to obtained a dewarped image, I only get an matrix of zeros and size of the original image as output. Here’s the data and the code:
load("calImg.mat")
J = double(calImg);
fixedPoints = W;
movingPoints = I;
figure(1)
imagesc(J)
tform = fitgeotform2d(movingPoints,fixedPoints,"projective");
Jregistered = imwarp(flipud(J),tform,OutputView=imref2d(size(J)));
figure(2)
imshowpair(I,Jregistered) I’m trying to reverse a transformation in an image. I have point coordinates in the intrinsic coordinate (moving points) and their equivalent in the real world coordinates (fixed points). When I use the fitgeotform2d and imwarp functions to obtained a dewarped image, I only get an matrix of zeros and size of the original image as output. Here’s the data and the code:
load("calImg.mat")
J = double(calImg);
fixedPoints = W;
movingPoints = I;
figure(1)
imagesc(J)
tform = fitgeotform2d(movingPoints,fixedPoints,"projective");
Jregistered = imwarp(flipud(J),tform,OutputView=imref2d(size(J)));
figure(2)
imshowpair(I,Jregistered) fitgeotform2d, imwarp, image processing, image analysis MATLAB Answers — New Questions
Support for Multiplication and Transpose of Block Matrices of Symbolic Matrices?
Does MATLAB not support multiplying and transposing block symbolic matrices? For instance, the following multiplication and transpose are not evaluated on the individual matrices inside of the block matrices:
syms A B C D E F G H [2 2] matrix
X = [A B;C D].’
Y = [A B;C D]*[E F;G H]
The outputs I am expecting are:
X = [A.’ C.’;B.’ D.’]
Y = [A*E+B*G A*F+B*H;C*E+D*G C*F+D*H]Does MATLAB not support multiplying and transposing block symbolic matrices? For instance, the following multiplication and transpose are not evaluated on the individual matrices inside of the block matrices:
syms A B C D E F G H [2 2] matrix
X = [A B;C D].’
Y = [A B;C D]*[E F;G H]
The outputs I am expecting are:
X = [A.’ C.’;B.’ D.’]
Y = [A*E+B*G A*F+B*H;C*E+D*G C*F+D*H] Does MATLAB not support multiplying and transposing block symbolic matrices? For instance, the following multiplication and transpose are not evaluated on the individual matrices inside of the block matrices:
syms A B C D E F G H [2 2] matrix
X = [A B;C D].’
Y = [A B;C D]*[E F;G H]
The outputs I am expecting are:
X = [A.’ C.’;B.’ D.’]
Y = [A*E+B*G A*F+B*H;C*E+D*G C*F+D*H] symbolic, block matrix, symbolic block matrix, symbolic matrix, symmatrix, symbolic matrix variable, multiplication, transpose, matlab, matrix, mathematics, livescript MATLAB Answers — New Questions
Show coordinates for a 2D point in a table cell
I’m working on a MATLAB app where I’m trying to dynamically record and show every mouse click on the UIAxes in a UItable.
My problem is that the table only shows "1×2 double" in the designated cell for the coordinates instead of the actual numbers.
Is this possible to fix or do I have to split them into two columns?
app.PointsTable.Data = table(‘Size’,[0 2],’VariableNames’, {‘Point’, ‘Coordinates’}, ‘VariableTypes’, {‘uint8’, ‘cell’});
function UIAxesButtonDown(app, event)
if 1
coordinates = app.UIAxes.CurrentPoint(1, 1:2);
numRows = size(app.PointsTable.Data, 1);
app.PointsTable.Data(numRows+1, 🙂 = {numRows+1, {[coordinates(1) coordinates(2)]}};
end
endI’m working on a MATLAB app where I’m trying to dynamically record and show every mouse click on the UIAxes in a UItable.
My problem is that the table only shows "1×2 double" in the designated cell for the coordinates instead of the actual numbers.
Is this possible to fix or do I have to split them into two columns?
app.PointsTable.Data = table(‘Size’,[0 2],’VariableNames’, {‘Point’, ‘Coordinates’}, ‘VariableTypes’, {‘uint8’, ‘cell’});
function UIAxesButtonDown(app, event)
if 1
coordinates = app.UIAxes.CurrentPoint(1, 1:2);
numRows = size(app.PointsTable.Data, 1);
app.PointsTable.Data(numRows+1, 🙂 = {numRows+1, {[coordinates(1) coordinates(2)]}};
end
end I’m working on a MATLAB app where I’m trying to dynamically record and show every mouse click on the UIAxes in a UItable.
My problem is that the table only shows "1×2 double" in the designated cell for the coordinates instead of the actual numbers.
Is this possible to fix or do I have to split them into two columns?
app.PointsTable.Data = table(‘Size’,[0 2],’VariableNames’, {‘Point’, ‘Coordinates’}, ‘VariableTypes’, {‘uint8’, ‘cell’});
function UIAxesButtonDown(app, event)
if 1
coordinates = app.UIAxes.CurrentPoint(1, 1:2);
numRows = size(app.PointsTable.Data, 1);
app.PointsTable.Data(numRows+1, 🙂 = {numRows+1, {[coordinates(1) coordinates(2)]}};
end
end uitable, cell MATLAB Answers — New Questions
I encounter a memory leak warning when i simulate my simulink model from a GA optimization code which iteratively simulate my model
Here’s the warning message :
Warning: Internal warning: A JITEngine loaded for block simulation cannot be freed due to non-zero reference count. It is usually caused by
unpaired calls to a block’s "setupRuntimeResources" and "cleanupRuntimeResources" methods.
> In optimising2_3 (line 209)
In Run_fuzzyGA_Tunning_R1 (line 79)Here’s the warning message :
Warning: Internal warning: A JITEngine loaded for block simulation cannot be freed due to non-zero reference count. It is usually caused by
unpaired calls to a block’s "setupRuntimeResources" and "cleanupRuntimeResources" methods.
> In optimising2_3 (line 209)
In Run_fuzzyGA_Tunning_R1 (line 79) Here’s the warning message :
Warning: Internal warning: A JITEngine loaded for block simulation cannot be freed due to non-zero reference count. It is usually caused by
unpaired calls to a block’s "setupRuntimeResources" and "cleanupRuntimeResources" methods.
> In optimising2_3 (line 209)
In Run_fuzzyGA_Tunning_R1 (line 79) simulink, setupruntimeresources, cleanupruntimeresources, jitengine MATLAB Answers — New Questions
Error: Data must be numeric, datetime, duration, categorical, or an array convertible to double.
Hello everyone,
I am trying to plot a function that has two different variables: theta and phi.
Theta = -pi/2:0.1:pi/2
Phi = Specific Values at 0 and pi/2
I have an error that says:
"Error: Data must be numeric, datetime, duration, categorical, or an array convertible to double."
I’ve tried looking up this error on different discussions. However, I wasn’t able to find anything that helped with my specific scenario.
I have tried different methods and approaches: Using "symbolic variables", fimplicit function, fplot function, etc. However, I got different errors everytime I tried a different approach.
I attached my code for reference:
Plotting_Theta_Phi_Function.mHello everyone,
I am trying to plot a function that has two different variables: theta and phi.
Theta = -pi/2:0.1:pi/2
Phi = Specific Values at 0 and pi/2
I have an error that says:
"Error: Data must be numeric, datetime, duration, categorical, or an array convertible to double."
I’ve tried looking up this error on different discussions. However, I wasn’t able to find anything that helped with my specific scenario.
I have tried different methods and approaches: Using "symbolic variables", fimplicit function, fplot function, etc. However, I got different errors everytime I tried a different approach.
I attached my code for reference:
Plotting_Theta_Phi_Function.m Hello everyone,
I am trying to plot a function that has two different variables: theta and phi.
Theta = -pi/2:0.1:pi/2
Phi = Specific Values at 0 and pi/2
I have an error that says:
"Error: Data must be numeric, datetime, duration, categorical, or an array convertible to double."
I’ve tried looking up this error on different discussions. However, I wasn’t able to find anything that helped with my specific scenario.
I have tried different methods and approaches: Using "symbolic variables", fimplicit function, fplot function, etc. However, I got different errors everytime I tried a different approach.
I attached my code for reference:
Plotting_Theta_Phi_Function.m plotting, functions MATLAB Answers — New Questions
How to create a summation looping through one matrix while keeping another one constant?
Hi,
I have a function "Func" that takes 2 inputs, 1 from each a different matrix (A and B). The matrices have same number of rows, but different number of columns.
My output matrix, C, takes the summation of Func’s output. For the entire row of matrix B, we will keep A constant. We will only go onto the next value of A when the B row is done. Additionally, we keep the rows the same such that only row 1 matrix B values will be used with row 1 A values. Row 2 matrix B with row 2 matrix A. etc. Here’s the demo code showing what I need it to do:
A = [1, 2, 3, 4;
5, 6, 7, 8;
9, 10, 11, 12];
B = [13, 14;
15, 16;
17, 18];
% Notes:
% Input A is a 3×4 matrix
% Input B is a 3×2 matrix
% Output C is going to be same dimensions as A, 3×4
% Function "Func" takes in inputs from A and B. syntax =
% Func(input from A, input from B)
% Example of how this is supposed to look:
% C(1,1) = Func(1,13) + Func(1,14)
% Above meaning the 1,1 entry of C matrix is the summation of the output of function "Func" where the inputs is A(1,1) and B(1,1) and B(1,2)
% C(1,2) = Func(2,13) + Func(2,14)
% C(1,3) = Func(3,13) + Func(3,14)
….
% C(2,1) = Func(5,15) + Func(5,16)
% Now that we are in the 2nd row, the "Func" function uses inputs A(2,1) and B(2,1) and B(2,2)
% C(2,2) = Func(6,15) + Func(6,16)
….
% C(3,1) = Func(9,17) + Func(9,18)
….
% C(3,4) = Func(12,17) + Func(12,18)
I know how to do this brute force, but I am struggling with how to approach this problem:
How many for loops do I need? (I currently have 2)
How do I get the loop to calculate the summation? Right now, my loop is only calculating the instaneous value, not summing.
Thanks!Hi,
I have a function "Func" that takes 2 inputs, 1 from each a different matrix (A and B). The matrices have same number of rows, but different number of columns.
My output matrix, C, takes the summation of Func’s output. For the entire row of matrix B, we will keep A constant. We will only go onto the next value of A when the B row is done. Additionally, we keep the rows the same such that only row 1 matrix B values will be used with row 1 A values. Row 2 matrix B with row 2 matrix A. etc. Here’s the demo code showing what I need it to do:
A = [1, 2, 3, 4;
5, 6, 7, 8;
9, 10, 11, 12];
B = [13, 14;
15, 16;
17, 18];
% Notes:
% Input A is a 3×4 matrix
% Input B is a 3×2 matrix
% Output C is going to be same dimensions as A, 3×4
% Function "Func" takes in inputs from A and B. syntax =
% Func(input from A, input from B)
% Example of how this is supposed to look:
% C(1,1) = Func(1,13) + Func(1,14)
% Above meaning the 1,1 entry of C matrix is the summation of the output of function "Func" where the inputs is A(1,1) and B(1,1) and B(1,2)
% C(1,2) = Func(2,13) + Func(2,14)
% C(1,3) = Func(3,13) + Func(3,14)
….
% C(2,1) = Func(5,15) + Func(5,16)
% Now that we are in the 2nd row, the "Func" function uses inputs A(2,1) and B(2,1) and B(2,2)
% C(2,2) = Func(6,15) + Func(6,16)
….
% C(3,1) = Func(9,17) + Func(9,18)
….
% C(3,4) = Func(12,17) + Func(12,18)
I know how to do this brute force, but I am struggling with how to approach this problem:
How many for loops do I need? (I currently have 2)
How do I get the loop to calculate the summation? Right now, my loop is only calculating the instaneous value, not summing.
Thanks! Hi,
I have a function "Func" that takes 2 inputs, 1 from each a different matrix (A and B). The matrices have same number of rows, but different number of columns.
My output matrix, C, takes the summation of Func’s output. For the entire row of matrix B, we will keep A constant. We will only go onto the next value of A when the B row is done. Additionally, we keep the rows the same such that only row 1 matrix B values will be used with row 1 A values. Row 2 matrix B with row 2 matrix A. etc. Here’s the demo code showing what I need it to do:
A = [1, 2, 3, 4;
5, 6, 7, 8;
9, 10, 11, 12];
B = [13, 14;
15, 16;
17, 18];
% Notes:
% Input A is a 3×4 matrix
% Input B is a 3×2 matrix
% Output C is going to be same dimensions as A, 3×4
% Function "Func" takes in inputs from A and B. syntax =
% Func(input from A, input from B)
% Example of how this is supposed to look:
% C(1,1) = Func(1,13) + Func(1,14)
% Above meaning the 1,1 entry of C matrix is the summation of the output of function "Func" where the inputs is A(1,1) and B(1,1) and B(1,2)
% C(1,2) = Func(2,13) + Func(2,14)
% C(1,3) = Func(3,13) + Func(3,14)
….
% C(2,1) = Func(5,15) + Func(5,16)
% Now that we are in the 2nd row, the "Func" function uses inputs A(2,1) and B(2,1) and B(2,2)
% C(2,2) = Func(6,15) + Func(6,16)
….
% C(3,1) = Func(9,17) + Func(9,18)
….
% C(3,4) = Func(12,17) + Func(12,18)
I know how to do this brute force, but I am struggling with how to approach this problem:
How many for loops do I need? (I currently have 2)
How do I get the loop to calculate the summation? Right now, my loop is only calculating the instaneous value, not summing.
Thanks! help, for loop, sum MATLAB Answers — New Questions
The command line isn’t working on matlab online, and the workspace and other features on the side bar also don’t seem to be working.
Pressing the command line button or the workspace button just extends the border it doesn’t actually open them up. Up until this point, I’ve been working in a .mlx file.Pressing the command line button or the workspace button just extends the border it doesn’t actually open them up. Up until this point, I’ve been working in a .mlx file. Pressing the command line button or the workspace button just extends the border it doesn’t actually open them up. Up until this point, I’ve been working in a .mlx file. command line, workspace MATLAB Answers — New Questions
When plotting multiple subplots in the for loop, how do you stop the axes from overlapping?
I am trying to plot the suplots in the for loop using the following code:
for k = 1:length(txt_files)
% some code
if PWM_switch == 1
ax1 = axes(t);
ax1.Layout.Tile = Test_Case;
if mod_switch == 1
if OpenLoop == 0
plot(table.data(:,1), table.data(:,2), ‘k’); hold on;
elseif OpenLoop == 1
plot(table.data(:,1), table.data(:,2), ‘k–‘); hold on;
end
end
if mod_switch == 4
if OpenLoop == 0
plot(table.data(:,1), table.data(:,2), ‘r’); hold on;
elseif OpenLoop == 1
plot(table.data(:,1), table.data(:,2), ‘r–‘); hold on;
end
end
end
end
but it appears that every time ax1 = axes(t) is executed, the supplot gets overlapping. You can still see old y-axis scales, but only the latest plots. When I run the loop step-by-step, all plots are plotted in the correct subplots; only they are overlapping.
I need to switch between subplots based on the conditions, i.e., Test Cases.
ax1.Layout.Tile = Test_Case correctly locates the subplot.
The full code with all *.txt files is in the attachment.I am trying to plot the suplots in the for loop using the following code:
for k = 1:length(txt_files)
% some code
if PWM_switch == 1
ax1 = axes(t);
ax1.Layout.Tile = Test_Case;
if mod_switch == 1
if OpenLoop == 0
plot(table.data(:,1), table.data(:,2), ‘k’); hold on;
elseif OpenLoop == 1
plot(table.data(:,1), table.data(:,2), ‘k–‘); hold on;
end
end
if mod_switch == 4
if OpenLoop == 0
plot(table.data(:,1), table.data(:,2), ‘r’); hold on;
elseif OpenLoop == 1
plot(table.data(:,1), table.data(:,2), ‘r–‘); hold on;
end
end
end
end
but it appears that every time ax1 = axes(t) is executed, the supplot gets overlapping. You can still see old y-axis scales, but only the latest plots. When I run the loop step-by-step, all plots are plotted in the correct subplots; only they are overlapping.
I need to switch between subplots based on the conditions, i.e., Test Cases.
ax1.Layout.Tile = Test_Case correctly locates the subplot.
The full code with all *.txt files is in the attachment. I am trying to plot the suplots in the for loop using the following code:
for k = 1:length(txt_files)
% some code
if PWM_switch == 1
ax1 = axes(t);
ax1.Layout.Tile = Test_Case;
if mod_switch == 1
if OpenLoop == 0
plot(table.data(:,1), table.data(:,2), ‘k’); hold on;
elseif OpenLoop == 1
plot(table.data(:,1), table.data(:,2), ‘k–‘); hold on;
end
end
if mod_switch == 4
if OpenLoop == 0
plot(table.data(:,1), table.data(:,2), ‘r’); hold on;
elseif OpenLoop == 1
plot(table.data(:,1), table.data(:,2), ‘r–‘); hold on;
end
end
end
end
but it appears that every time ax1 = axes(t) is executed, the supplot gets overlapping. You can still see old y-axis scales, but only the latest plots. When I run the loop step-by-step, all plots are plotted in the correct subplots; only they are overlapping.
I need to switch between subplots based on the conditions, i.e., Test Cases.
ax1.Layout.Tile = Test_Case correctly locates the subplot.
The full code with all *.txt files is in the attachment. plotting, subplot, axes MATLAB Answers — New Questions
System Composer addition to suite
System composer cannot be learned in just a few days or weeks. I have a home license so I can learn and apply to the commercial version when able. I have purchased many of the home licenses…seems silly that I cannot prepare (learn) for a commercial MBSE endeavor. When look for the compatible version price I CANNOT find it.System composer cannot be learned in just a few days or weeks. I have a home license so I can learn and apply to the commercial version when able. I have purchased many of the home licenses…seems silly that I cannot prepare (learn) for a commercial MBSE endeavor. When look for the compatible version price I CANNOT find it. System composer cannot be learned in just a few days or weeks. I have a home license so I can learn and apply to the commercial version when able. I have purchased many of the home licenses…seems silly that I cannot prepare (learn) for a commercial MBSE endeavor. When look for the compatible version price I CANNOT find it. simulink composer MATLAB Answers — New Questions
uigetfile canceled returns 0, converting my string to a scalar
when I call [infile, location] = uigetfile() and it’s canceled, it returns 0s, converting my strings to a scalars
Next time I call it I get an error:
Error using uigetputfile_helper/checkString
Filename must be a character vector or a string scalar.
How do I get my string back for infile to be properly used next time?
This shouldn’t be that hard! I even tried converting the vars back to strings but it still fails after a cancel loop
function LoadfromTextFileButtonPushed(app, event)
% Open the file in the Load trials text
if isempty(app.loc)
[infile, app.loc] = uigetfile(‘*.txt’,’Select a Stimulus File’,app.defLoc);
else
[infile, app.loc] = uigetfile(‘*.txt’,’Select a Stimulus File’,app.loc);
end
if infile == 0 % user canceled
app.FileName.Text = ‘Click Load From Text File or enter manually’;
% give me back a string var for next time
infile = ”;
app.loc = app.defLoc; % return to default string
return;
end
% Put full file name into the File field name and read it in
locfile = fullfile(app.loc,infile);
app.FileName.Text = locfile;
app.UITable2.Data = readtable(locfile);
endwhen I call [infile, location] = uigetfile() and it’s canceled, it returns 0s, converting my strings to a scalars
Next time I call it I get an error:
Error using uigetputfile_helper/checkString
Filename must be a character vector or a string scalar.
How do I get my string back for infile to be properly used next time?
This shouldn’t be that hard! I even tried converting the vars back to strings but it still fails after a cancel loop
function LoadfromTextFileButtonPushed(app, event)
% Open the file in the Load trials text
if isempty(app.loc)
[infile, app.loc] = uigetfile(‘*.txt’,’Select a Stimulus File’,app.defLoc);
else
[infile, app.loc] = uigetfile(‘*.txt’,’Select a Stimulus File’,app.loc);
end
if infile == 0 % user canceled
app.FileName.Text = ‘Click Load From Text File or enter manually’;
% give me back a string var for next time
infile = ”;
app.loc = app.defLoc; % return to default string
return;
end
% Put full file name into the File field name and read it in
locfile = fullfile(app.loc,infile);
app.FileName.Text = locfile;
app.UITable2.Data = readtable(locfile);
end when I call [infile, location] = uigetfile() and it’s canceled, it returns 0s, converting my strings to a scalars
Next time I call it I get an error:
Error using uigetputfile_helper/checkString
Filename must be a character vector or a string scalar.
How do I get my string back for infile to be properly used next time?
This shouldn’t be that hard! I even tried converting the vars back to strings but it still fails after a cancel loop
function LoadfromTextFileButtonPushed(app, event)
% Open the file in the Load trials text
if isempty(app.loc)
[infile, app.loc] = uigetfile(‘*.txt’,’Select a Stimulus File’,app.defLoc);
else
[infile, app.loc] = uigetfile(‘*.txt’,’Select a Stimulus File’,app.loc);
end
if infile == 0 % user canceled
app.FileName.Text = ‘Click Load From Text File or enter manually’;
% give me back a string var for next time
infile = ”;
app.loc = app.defLoc; % return to default string
return;
end
% Put full file name into the File field name and read it in
locfile = fullfile(app.loc,infile);
app.FileName.Text = locfile;
app.UITable2.Data = readtable(locfile);
end uigetfile, cancel MATLAB Answers — New Questions
Error message “‘sequenceInputLayer requires Deep Learning Toolbox” running MATLAB from terminal
I am training an LSTM network (script called lstm_classification.m) on some time series data (MATLAB R2024a). Training uses the Deep Learning toolbox which is installed correctly. When I run the script from the GUI everything works fine, but when I call the script from R, I get the following error message:
sequenceInputLayer requires Deep Learning Toolbox.
Error in lstm_classification (line 463) sequenceInputLayer(inputSize)
Error in run (line 112)
evalin(‘caller’, strcat(script, ‘;’));
Calling the script from R used to work without issues. This error message occured only recently. This is my script lstm_classification.m around line 463 (sequenceInputLayer…):
…
%% Define LSTM Network Architecture
inputSize=nofeatures;
% numHiddenUnits=100;
numHiddenUnits=hiddenunits;
% numClasses=9;
numClasses=notreatments_afterdrop;
layers=[ …
sequenceInputLayer(inputSize)
bilstmLayer(numHiddenUnits,’OutputMode’,’last’)
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer
];
…
What is the matter here? Is the toolbox now not accesible without the MATLAB-GUI running? It used to work perfectly. Any help is greatly appreciated. Thanks.I am training an LSTM network (script called lstm_classification.m) on some time series data (MATLAB R2024a). Training uses the Deep Learning toolbox which is installed correctly. When I run the script from the GUI everything works fine, but when I call the script from R, I get the following error message:
sequenceInputLayer requires Deep Learning Toolbox.
Error in lstm_classification (line 463) sequenceInputLayer(inputSize)
Error in run (line 112)
evalin(‘caller’, strcat(script, ‘;’));
Calling the script from R used to work without issues. This error message occured only recently. This is my script lstm_classification.m around line 463 (sequenceInputLayer…):
…
%% Define LSTM Network Architecture
inputSize=nofeatures;
% numHiddenUnits=100;
numHiddenUnits=hiddenunits;
% numClasses=9;
numClasses=notreatments_afterdrop;
layers=[ …
sequenceInputLayer(inputSize)
bilstmLayer(numHiddenUnits,’OutputMode’,’last’)
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer
];
…
What is the matter here? Is the toolbox now not accesible without the MATLAB-GUI running? It used to work perfectly. Any help is greatly appreciated. Thanks. I am training an LSTM network (script called lstm_classification.m) on some time series data (MATLAB R2024a). Training uses the Deep Learning toolbox which is installed correctly. When I run the script from the GUI everything works fine, but when I call the script from R, I get the following error message:
sequenceInputLayer requires Deep Learning Toolbox.
Error in lstm_classification (line 463) sequenceInputLayer(inputSize)
Error in run (line 112)
evalin(‘caller’, strcat(script, ‘;’));
Calling the script from R used to work without issues. This error message occured only recently. This is my script lstm_classification.m around line 463 (sequenceInputLayer…):
…
%% Define LSTM Network Architecture
inputSize=nofeatures;
% numHiddenUnits=100;
numHiddenUnits=hiddenunits;
% numClasses=9;
numClasses=notreatments_afterdrop;
layers=[ …
sequenceInputLayer(inputSize)
bilstmLayer(numHiddenUnits,’OutputMode’,’last’)
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer
];
…
What is the matter here? Is the toolbox now not accesible without the MATLAB-GUI running? It used to work perfectly. Any help is greatly appreciated. Thanks. sequenceinputlayer, deeplearning toolbox MATLAB Answers — New Questions
how to configure the block simulink block related to LDPC coded with MQAM and OFDM over AWGN and Rayleigh channel
i build block which as follow: integer source generator >>>LDPC encoder>>> 16QAM >>>Rayleigh fading and AWGN channel >>>then the inverse of previous steps and i add ber calculation and to workspace simout to plot relation between Eb/No vs BER ..
but the simulink doesnot run because of issue in configurations …
so kindly i need the help to understand configuration
the attached is the filei build block which as follow: integer source generator >>>LDPC encoder>>> 16QAM >>>Rayleigh fading and AWGN channel >>>then the inverse of previous steps and i add ber calculation and to workspace simout to plot relation between Eb/No vs BER ..
but the simulink doesnot run because of issue in configurations …
so kindly i need the help to understand configuration
the attached is the file i build block which as follow: integer source generator >>>LDPC encoder>>> 16QAM >>>Rayleigh fading and AWGN channel >>>then the inverse of previous steps and i add ber calculation and to workspace simout to plot relation between Eb/No vs BER ..
but the simulink doesnot run because of issue in configurations …
so kindly i need the help to understand configuration
the attached is the file wireless communication, digital communication, error correction code, ofdm, ldpc, qam MATLAB Answers — New Questions
jetson camera image is rotated on target device
I am attempting to run this example:
https://www.mathworks.com/help/coder/nvidia/ug/deploy-and-run-sobel-edge-detection-with-i-o-on-nvidia-jetson.html
Everything works great but for some reason the camera window and image are rotated -90 degrees. Is there a way to send a message to rotate the image? when I run this command on the target: ffplay /dev/video0, it looks fine.I am attempting to run this example:
https://www.mathworks.com/help/coder/nvidia/ug/deploy-and-run-sobel-edge-detection-with-i-o-on-nvidia-jetson.html
Everything works great but for some reason the camera window and image are rotated -90 degrees. Is there a way to send a message to rotate the image? when I run this command on the target: ffplay /dev/video0, it looks fine. I am attempting to run this example:
https://www.mathworks.com/help/coder/nvidia/ug/deploy-and-run-sobel-edge-detection-with-i-o-on-nvidia-jetson.html
Everything works great but for some reason the camera window and image are rotated -90 degrees. Is there a way to send a message to rotate the image? when I run this command on the target: ffplay /dev/video0, it looks fine. jetson, gpu coder, video, webcam, display MATLAB Answers — New Questions
How to use contourf to plot a mesh not generated in matlab, i.e. imported mesh coordinates from abaqus. The issue is that coordinates are not sequential.
I’m trying to use contourf with x and y coordinates being random or non sequential. I have z value for each X y coordinate. Normaly we would create a rectangular mesh and then fill up the z values. Here the issue is that the geometry is meshed in abaqus and the mesh nodes and element related information is fed to my code. Now the nodes are not sequential matrix.I’m trying to use contourf with x and y coordinates being random or non sequential. I have z value for each X y coordinate. Normaly we would create a rectangular mesh and then fill up the z values. Here the issue is that the geometry is meshed in abaqus and the mesh nodes and element related information is fed to my code. Now the nodes are not sequential matrix. I’m trying to use contourf with x and y coordinates being random or non sequential. I have z value for each X y coordinate. Normaly we would create a rectangular mesh and then fill up the z values. Here the issue is that the geometry is meshed in abaqus and the mesh nodes and element related information is fed to my code. Now the nodes are not sequential matrix. contourf, meshing coordinates, abaqus mesh. MATLAB Answers — New Questions
MRI T1 Map production from multiple Flip Angles
I’ve edited a MATLAB code that produces a T1 map from two flip angles. I have MRI slices that are 5×170 slices for 5 different flip angles (2,10,11,12,13). I converted them into .nii files and performed the matlab code which worked. It displays 2 rows of T1 maps for each set of angles. The first row of images represent the T1 values from the initial iteration, which are essentially the initial guesses of the T1 relaxation times. These values are based on the raw data without the iterative refinement process applied. The second row of images represent the T1 values after the iterative refinement process has been completed (after 10 iterations). These values are more accurate and have been corrected for residual T1 saturation effects through the iterative process. However, my T1 maps that came out have a lot of noise especially in the background and don’t look like a normal T1 map, can anyone help me understand why this might be?I’ve edited a MATLAB code that produces a T1 map from two flip angles. I have MRI slices that are 5×170 slices for 5 different flip angles (2,10,11,12,13). I converted them into .nii files and performed the matlab code which worked. It displays 2 rows of T1 maps for each set of angles. The first row of images represent the T1 values from the initial iteration, which are essentially the initial guesses of the T1 relaxation times. These values are based on the raw data without the iterative refinement process applied. The second row of images represent the T1 values after the iterative refinement process has been completed (after 10 iterations). These values are more accurate and have been corrected for residual T1 saturation effects through the iterative process. However, my T1 maps that came out have a lot of noise especially in the background and don’t look like a normal T1 map, can anyone help me understand why this might be? I’ve edited a MATLAB code that produces a T1 map from two flip angles. I have MRI slices that are 5×170 slices for 5 different flip angles (2,10,11,12,13). I converted them into .nii files and performed the matlab code which worked. It displays 2 rows of T1 maps for each set of angles. The first row of images represent the T1 values from the initial iteration, which are essentially the initial guesses of the T1 relaxation times. These values are based on the raw data without the iterative refinement process applied. The second row of images represent the T1 values after the iterative refinement process has been completed (after 10 iterations). These values are more accurate and have been corrected for residual T1 saturation effects through the iterative process. However, my T1 maps that came out have a lot of noise especially in the background and don’t look like a normal T1 map, can anyone help me understand why this might be? mri, t1 map MATLAB Answers — New Questions