Category: Matlab
Category Archives: Matlab
Change in the gradient of points in 3D space with respect to its neighbour.
Hello matlab Community,
Is there any function in Matlab to find the gradient change of a point in 3d space with respect to its neighbour point"?
I have sutface coordinates of approximately 15000 points (.STL file contains this). Now i want to find the gradient change of each point with resppecte to its neighbour.
I am attaching .STL file which contain coordinates of all the surface point.
It can be read in matlab using
TR=stlread(‘aggrgate_1.stl’);
trimesh(TR);Hello matlab Community,
Is there any function in Matlab to find the gradient change of a point in 3d space with respect to its neighbour point"?
I have sutface coordinates of approximately 15000 points (.STL file contains this). Now i want to find the gradient change of each point with resppecte to its neighbour.
I am attaching .STL file which contain coordinates of all the surface point.
It can be read in matlab using
TR=stlread(‘aggrgate_1.stl’);
trimesh(TR); Hello matlab Community,
Is there any function in Matlab to find the gradient change of a point in 3d space with respect to its neighbour point"?
I have sutface coordinates of approximately 15000 points (.STL file contains this). Now i want to find the gradient change of each point with resppecte to its neighbour.
I am attaching .STL file which contain coordinates of all the surface point.
It can be read in matlab using
TR=stlread(‘aggrgate_1.stl’);
trimesh(TR); gradient change, stl MATLAB Answers — New Questions
Issue with integration using trapz
Hello,
I’m trying to implement integration using trapz. But the resultant quantity after integration is negligibly small and doesn’t increment. Am I doing something wrong which is confusing me.
Can you see and advice me the chnages if any.
num=15;
Iq(1)=eps;
for i=2:11
Iq(i)=trapz(X(1:i),X(1:i).*jd0.*(1-(X(1:i)-x0).^2).^num);
end
Here, x0=1
rgds,
rcHello,
I’m trying to implement integration using trapz. But the resultant quantity after integration is negligibly small and doesn’t increment. Am I doing something wrong which is confusing me.
Can you see and advice me the chnages if any.
num=15;
Iq(1)=eps;
for i=2:11
Iq(i)=trapz(X(1:i),X(1:i).*jd0.*(1-(X(1:i)-x0).^2).^num);
end
Here, x0=1
rgds,
rc Hello,
I’m trying to implement integration using trapz. But the resultant quantity after integration is negligibly small and doesn’t increment. Am I doing something wrong which is confusing me.
Can you see and advice me the chnages if any.
num=15;
Iq(1)=eps;
for i=2:11
Iq(i)=trapz(X(1:i),X(1:i).*jd0.*(1-(X(1:i)-x0).^2).^num);
end
Here, x0=1
rgds,
rc trapz MATLAB Answers — New Questions
Specialized Power Systems Multimeter Block
Is there a way to extract numerical results from the phasor analysis of the multimeter block?
What is the output format of this block and how to separate the output measurements into individual items?Is there a way to extract numerical results from the phasor analysis of the multimeter block?
What is the output format of this block and how to separate the output measurements into individual items? Is there a way to extract numerical results from the phasor analysis of the multimeter block?
What is the output format of this block and how to separate the output measurements into individual items? specialized power system, multimeter measurements MATLAB Answers — New Questions
Negative variance of state when training.
For our image segmentation task, we are trying to implement a custom training loop for our network, giving us more freedom to visualize predictions while training. Bellow follows parts of the code that should be key in identifying the underlying issue:
%% Classes
classNames = ["bg", "live", "nk", "round", "blob", "other"];
labelIDs = [0 192 255 1 2 3];
numClasses = 6;
%% Create mobilenet
network = ‘mobilenetv2’;
lgraph = deeplabv3plusLayers([224 224 3],numClasses,network);
% X our whole trainig data
[m, s] = calculate_input_params(single(X));
input_layer_new = imageInputLayer([224 224 3], "Normalization","zscore", "Mean",m, "StandardDeviation",s);
lgraph = replaceLayer(lgraph, "input_1", input_layer_new);
lgraph = removeLayers(lgraph, "classification");
%% Initialize network, training data and parameters
net = dlnetwork(lgraph);
mbq = minibatchqueue(ds_augmented, "MiniBatchSize",16, "MiniBatchFormat",["SSCB" "SSB"]);
numepochs = 3;
initialLearnRate = 0.01;
decay = 0.01;
momentum = 0.9;
vel = [];
%% Necessary code to avoid error
try
nnet.internal.cnngpu.reluForward(1);
catch ME
end
%% Train network
epoch = 0;
iteration = 0;
while epoch < numepochs
epoch = epoch + 1;
shuffle(mbq);
while hasdata(mbq)
iteration = iteration + 1;
epoch_iteration = [epoch iteration]
[X_b, Y_b] = next(mbq);
Y_b = adjust_dimensions(Y_b);
[loss,gradients,state] = dlfeval(@modelLoss,net,X_b,Y_b);
net.State = state;
loss
learnRate = initialLearnRate/(1 + decay*iteration);
[net, vel] = sgdmupdate(net, gradients, vel, learnRate, momentum);
end
end
function [loss,gradients,state] = modelLoss(net,X_b,Y_b)
classWeights = [1 10 10 10 10 10];
% Forward data through network.
[Y_p,state] = forward(net,X_b);
% Calculate cross-entropy loss.
loss = crossentropy(Y_p,Y_b,classWeights,’WeightsFormat’,’UC’,’TargetCategories’,’independent’);
% Calculate gradients of loss with respect to learnable parameters.
gradients = dlgradient(loss,net.Learnables);
end
Essentialy, when we run the Train network section, we manage to run a couple of iterations (number of iterations may vary), untill we get the following error:
Along this, we have noticed that no matter how many iterations we run, when we access X_b, Y_b, Y_p and try to visualize the first and second image of the batch, we always get the same prediction regardless of X_b and Y_b. It seems that Y_p that is generated from forwad(net, X_b) is somehow constant:
Since me and my lab partner do not pocess any formal training in deep learning and image segmentation, we find it challenging to connect the dots and overcome this problem. Any feedback regarding code or approach would be much appreciated.For our image segmentation task, we are trying to implement a custom training loop for our network, giving us more freedom to visualize predictions while training. Bellow follows parts of the code that should be key in identifying the underlying issue:
%% Classes
classNames = ["bg", "live", "nk", "round", "blob", "other"];
labelIDs = [0 192 255 1 2 3];
numClasses = 6;
%% Create mobilenet
network = ‘mobilenetv2’;
lgraph = deeplabv3plusLayers([224 224 3],numClasses,network);
% X our whole trainig data
[m, s] = calculate_input_params(single(X));
input_layer_new = imageInputLayer([224 224 3], "Normalization","zscore", "Mean",m, "StandardDeviation",s);
lgraph = replaceLayer(lgraph, "input_1", input_layer_new);
lgraph = removeLayers(lgraph, "classification");
%% Initialize network, training data and parameters
net = dlnetwork(lgraph);
mbq = minibatchqueue(ds_augmented, "MiniBatchSize",16, "MiniBatchFormat",["SSCB" "SSB"]);
numepochs = 3;
initialLearnRate = 0.01;
decay = 0.01;
momentum = 0.9;
vel = [];
%% Necessary code to avoid error
try
nnet.internal.cnngpu.reluForward(1);
catch ME
end
%% Train network
epoch = 0;
iteration = 0;
while epoch < numepochs
epoch = epoch + 1;
shuffle(mbq);
while hasdata(mbq)
iteration = iteration + 1;
epoch_iteration = [epoch iteration]
[X_b, Y_b] = next(mbq);
Y_b = adjust_dimensions(Y_b);
[loss,gradients,state] = dlfeval(@modelLoss,net,X_b,Y_b);
net.State = state;
loss
learnRate = initialLearnRate/(1 + decay*iteration);
[net, vel] = sgdmupdate(net, gradients, vel, learnRate, momentum);
end
end
function [loss,gradients,state] = modelLoss(net,X_b,Y_b)
classWeights = [1 10 10 10 10 10];
% Forward data through network.
[Y_p,state] = forward(net,X_b);
% Calculate cross-entropy loss.
loss = crossentropy(Y_p,Y_b,classWeights,’WeightsFormat’,’UC’,’TargetCategories’,’independent’);
% Calculate gradients of loss with respect to learnable parameters.
gradients = dlgradient(loss,net.Learnables);
end
Essentialy, when we run the Train network section, we manage to run a couple of iterations (number of iterations may vary), untill we get the following error:
Along this, we have noticed that no matter how many iterations we run, when we access X_b, Y_b, Y_p and try to visualize the first and second image of the batch, we always get the same prediction regardless of X_b and Y_b. It seems that Y_p that is generated from forwad(net, X_b) is somehow constant:
Since me and my lab partner do not pocess any formal training in deep learning and image segmentation, we find it challenging to connect the dots and overcome this problem. Any feedback regarding code or approach would be much appreciated. For our image segmentation task, we are trying to implement a custom training loop for our network, giving us more freedom to visualize predictions while training. Bellow follows parts of the code that should be key in identifying the underlying issue:
%% Classes
classNames = ["bg", "live", "nk", "round", "blob", "other"];
labelIDs = [0 192 255 1 2 3];
numClasses = 6;
%% Create mobilenet
network = ‘mobilenetv2’;
lgraph = deeplabv3plusLayers([224 224 3],numClasses,network);
% X our whole trainig data
[m, s] = calculate_input_params(single(X));
input_layer_new = imageInputLayer([224 224 3], "Normalization","zscore", "Mean",m, "StandardDeviation",s);
lgraph = replaceLayer(lgraph, "input_1", input_layer_new);
lgraph = removeLayers(lgraph, "classification");
%% Initialize network, training data and parameters
net = dlnetwork(lgraph);
mbq = minibatchqueue(ds_augmented, "MiniBatchSize",16, "MiniBatchFormat",["SSCB" "SSB"]);
numepochs = 3;
initialLearnRate = 0.01;
decay = 0.01;
momentum = 0.9;
vel = [];
%% Necessary code to avoid error
try
nnet.internal.cnngpu.reluForward(1);
catch ME
end
%% Train network
epoch = 0;
iteration = 0;
while epoch < numepochs
epoch = epoch + 1;
shuffle(mbq);
while hasdata(mbq)
iteration = iteration + 1;
epoch_iteration = [epoch iteration]
[X_b, Y_b] = next(mbq);
Y_b = adjust_dimensions(Y_b);
[loss,gradients,state] = dlfeval(@modelLoss,net,X_b,Y_b);
net.State = state;
loss
learnRate = initialLearnRate/(1 + decay*iteration);
[net, vel] = sgdmupdate(net, gradients, vel, learnRate, momentum);
end
end
function [loss,gradients,state] = modelLoss(net,X_b,Y_b)
classWeights = [1 10 10 10 10 10];
% Forward data through network.
[Y_p,state] = forward(net,X_b);
% Calculate cross-entropy loss.
loss = crossentropy(Y_p,Y_b,classWeights,’WeightsFormat’,’UC’,’TargetCategories’,’independent’);
% Calculate gradients of loss with respect to learnable parameters.
gradients = dlgradient(loss,net.Learnables);
end
Essentialy, when we run the Train network section, we manage to run a couple of iterations (number of iterations may vary), untill we get the following error:
Along this, we have noticed that no matter how many iterations we run, when we access X_b, Y_b, Y_p and try to visualize the first and second image of the batch, we always get the same prediction regardless of X_b and Y_b. It seems that Y_p that is generated from forwad(net, X_b) is somehow constant:
Since me and my lab partner do not pocess any formal training in deep learning and image segmentation, we find it challenging to connect the dots and overcome this problem. Any feedback regarding code or approach would be much appreciated. image segmentation, custom training loop, deep learning, negative trainedvariance MATLAB Answers — New Questions
How to maintain variable values between stateflow transitions
Hello,
I have a stateflow model which is modeling the State of Charge (SOC) of a battery as it cycles between charging and discharging. The stateflow diagram starts in charge and the SOC increases relative to the amount of time the charge is activated, and then the diagram transitions to discharge and the SOC decreases to relative to the amount of time the discharge state is activated. The SOC must maintain its value persisently through ‘charge’ and ‘discharge’ however everytime one cycle is completed and the stateflow transitions from discharge back to charge, SOC is reset. How do I avoid this reset? I want SOC to persist through multiple cycles and not be reset after each cycle.Hello,
I have a stateflow model which is modeling the State of Charge (SOC) of a battery as it cycles between charging and discharging. The stateflow diagram starts in charge and the SOC increases relative to the amount of time the charge is activated, and then the diagram transitions to discharge and the SOC decreases to relative to the amount of time the discharge state is activated. The SOC must maintain its value persisently through ‘charge’ and ‘discharge’ however everytime one cycle is completed and the stateflow transitions from discharge back to charge, SOC is reset. How do I avoid this reset? I want SOC to persist through multiple cycles and not be reset after each cycle. Hello,
I have a stateflow model which is modeling the State of Charge (SOC) of a battery as it cycles between charging and discharging. The stateflow diagram starts in charge and the SOC increases relative to the amount of time the charge is activated, and then the diagram transitions to discharge and the SOC decreases to relative to the amount of time the discharge state is activated. The SOC must maintain its value persisently through ‘charge’ and ‘discharge’ however everytime one cycle is completed and the stateflow transitions from discharge back to charge, SOC is reset. How do I avoid this reset? I want SOC to persist through multiple cycles and not be reset after each cycle. stateflow, variables MATLAB Answers — New Questions
How to customize function name for e-coder generated lookup table file?
I’m having trouble ingrating e-coder generated files for 2 models as both models generate similar functions for a lookup table, except datatype of 1 of the inputs to the function. Is there a way to customize function names for lookup tables?I’m having trouble ingrating e-coder generated files for 2 models as both models generate similar functions for a lookup table, except datatype of 1 of the inputs to the function. Is there a way to customize function names for lookup tables? I’m having trouble ingrating e-coder generated files for 2 models as both models generate similar functions for a lookup table, except datatype of 1 of the inputs to the function. Is there a way to customize function names for lookup tables? lookup table MATLAB Answers — New Questions
How to automatically add some code content at any place in the code generated by simulink
simulink code:
/* Const memory section */
/* Definition for custom storage class: Const */
const uint8_T SFCMM_ABSFunc_Active = 1U;/* Referenced by:
* ‘<S35>/Constant127’
* ‘<S35>/Constant90’
* ‘<S104>/Constant127’
* ‘<S104>/Constant90’
* ‘<S151>/Constant127’
* ‘<S151>/Constant90’
*/
const uint8_T SFCMM_AEBFuncConfig_Open = 1U;/* Referenced by: ‘<S9>/Constant15’ */
const uint8_T SFCMM_AEBFuncSwitch_Open = 1U;/* Referenced by: ‘<S9>/Constant17’ */
Object Code:
#define ASW_QM_COM_MODULE_START_SEC_CONST_UNSPECIFIED
#include "ASW_MemMap.h"
/* Const memory section */
/* Definition for custom storage class: Const */
const uint8_T SFCMM_ABSFunc_Active = 1U;/* Referenced by:
* ‘<S35>/Constant127’
* ‘<S35>/Constant90’
* ‘<S104>/Constant127’
* ‘<S104>/Constant90’
* ‘<S151>/Constant127’
* ‘<S151>/Constant90’
*/
const uint8_T SFCMM_AEBFuncConfig_Open = 1U;/* Referenced by: ‘<S9>/Constant15’ */
const uint8_T SFCMM_AEBFuncSwitch_Open = 1U;/* Referenced by: ‘<S9>/Constant17’ */
#define ASW_QM_COM_MODULE_STOP_SEC_CONST_UNSPECIFIED
include "ASW_MemMap.h"
how to add “#define ASW_QM_COM_MODULE_START_SEC_CONST_UNSPECIFIED #include "ASW_MemMap.h” and“#define ASW_QM_COM_MODULE_STOP_SEC_CONST_UNSPECIFIED include "ASW_MemMap.h"” in front of "/* Const memory section */ " and
behind "const uint8_T SFCMM_AEBFuncSwitch_Open = 1U;/* Referenced by: ‘<S9>/Constant17’ */"simulink code:
/* Const memory section */
/* Definition for custom storage class: Const */
const uint8_T SFCMM_ABSFunc_Active = 1U;/* Referenced by:
* ‘<S35>/Constant127’
* ‘<S35>/Constant90’
* ‘<S104>/Constant127’
* ‘<S104>/Constant90’
* ‘<S151>/Constant127’
* ‘<S151>/Constant90’
*/
const uint8_T SFCMM_AEBFuncConfig_Open = 1U;/* Referenced by: ‘<S9>/Constant15’ */
const uint8_T SFCMM_AEBFuncSwitch_Open = 1U;/* Referenced by: ‘<S9>/Constant17’ */
Object Code:
#define ASW_QM_COM_MODULE_START_SEC_CONST_UNSPECIFIED
#include "ASW_MemMap.h"
/* Const memory section */
/* Definition for custom storage class: Const */
const uint8_T SFCMM_ABSFunc_Active = 1U;/* Referenced by:
* ‘<S35>/Constant127’
* ‘<S35>/Constant90’
* ‘<S104>/Constant127’
* ‘<S104>/Constant90’
* ‘<S151>/Constant127’
* ‘<S151>/Constant90’
*/
const uint8_T SFCMM_AEBFuncConfig_Open = 1U;/* Referenced by: ‘<S9>/Constant15’ */
const uint8_T SFCMM_AEBFuncSwitch_Open = 1U;/* Referenced by: ‘<S9>/Constant17’ */
#define ASW_QM_COM_MODULE_STOP_SEC_CONST_UNSPECIFIED
include "ASW_MemMap.h"
how to add “#define ASW_QM_COM_MODULE_START_SEC_CONST_UNSPECIFIED #include "ASW_MemMap.h” and“#define ASW_QM_COM_MODULE_STOP_SEC_CONST_UNSPECIFIED include "ASW_MemMap.h"” in front of "/* Const memory section */ " and
behind "const uint8_T SFCMM_AEBFuncSwitch_Open = 1U;/* Referenced by: ‘<S9>/Constant17’ */" simulink code:
/* Const memory section */
/* Definition for custom storage class: Const */
const uint8_T SFCMM_ABSFunc_Active = 1U;/* Referenced by:
* ‘<S35>/Constant127’
* ‘<S35>/Constant90’
* ‘<S104>/Constant127’
* ‘<S104>/Constant90’
* ‘<S151>/Constant127’
* ‘<S151>/Constant90’
*/
const uint8_T SFCMM_AEBFuncConfig_Open = 1U;/* Referenced by: ‘<S9>/Constant15’ */
const uint8_T SFCMM_AEBFuncSwitch_Open = 1U;/* Referenced by: ‘<S9>/Constant17’ */
Object Code:
#define ASW_QM_COM_MODULE_START_SEC_CONST_UNSPECIFIED
#include "ASW_MemMap.h"
/* Const memory section */
/* Definition for custom storage class: Const */
const uint8_T SFCMM_ABSFunc_Active = 1U;/* Referenced by:
* ‘<S35>/Constant127’
* ‘<S35>/Constant90’
* ‘<S104>/Constant127’
* ‘<S104>/Constant90’
* ‘<S151>/Constant127’
* ‘<S151>/Constant90’
*/
const uint8_T SFCMM_AEBFuncConfig_Open = 1U;/* Referenced by: ‘<S9>/Constant15’ */
const uint8_T SFCMM_AEBFuncSwitch_Open = 1U;/* Referenced by: ‘<S9>/Constant17’ */
#define ASW_QM_COM_MODULE_STOP_SEC_CONST_UNSPECIFIED
include "ASW_MemMap.h"
how to add “#define ASW_QM_COM_MODULE_START_SEC_CONST_UNSPECIFIED #include "ASW_MemMap.h” and“#define ASW_QM_COM_MODULE_STOP_SEC_CONST_UNSPECIFIED include "ASW_MemMap.h"” in front of "/* Const memory section */ " and
behind "const uint8_T SFCMM_AEBFuncSwitch_Open = 1U;/* Referenced by: ‘<S9>/Constant17’ */" code generation MATLAB Answers — New Questions
export of coefficients from FDATool into Workspace
I exported a coefficient from the FDATool but when I run the script with the coefficient, the coefficient disappears from the workspace and ‘Undefined function or variable ‘Num’.’ appears as the error.
But when the same command is entered into the Command Window, it is running perfectly and the variable from the workspace does not disappear.
Please Help.I exported a coefficient from the FDATool but when I run the script with the coefficient, the coefficient disappears from the workspace and ‘Undefined function or variable ‘Num’.’ appears as the error.
But when the same command is entered into the Command Window, it is running perfectly and the variable from the workspace does not disappear.
Please Help. I exported a coefficient from the FDATool but when I run the script with the coefficient, the coefficient disappears from the workspace and ‘Undefined function or variable ‘Num’.’ appears as the error.
But when the same command is entered into the Command Window, it is running perfectly and the variable from the workspace does not disappear.
Please Help. exporting coefficients MATLAB Answers — New Questions
Read rosbag file – change between R2018b to R2020b
Hi,
In MATLAB R2018b I was using the command
Bag = rosbag(RosbagFileName)
and it was working fine.
When trying to use the same command with the same file on MATLAB R2020, I get the follwoing error:
The class ros.Bag has no Constant property or Static method named ‘parse’.
Any idea what could be the problem?Hi,
In MATLAB R2018b I was using the command
Bag = rosbag(RosbagFileName)
and it was working fine.
When trying to use the same command with the same file on MATLAB R2020, I get the follwoing error:
The class ros.Bag has no Constant property or Static method named ‘parse’.
Any idea what could be the problem? Hi,
In MATLAB R2018b I was using the command
Bag = rosbag(RosbagFileName)
and it was working fine.
When trying to use the same command with the same file on MATLAB R2020, I get the follwoing error:
The class ros.Bag has no Constant property or Static method named ‘parse’.
Any idea what could be the problem? rosbag, read rosbag, r2018b, r2020b MATLAB Answers — New Questions
ROS simulink controller is slow
I am trying to build a controller in simulink to interact with ROS and custom simulation of my robot. The controller is rather complex, and involves communication with several topics.
When I try to publish the setpoints to the controller the controller runs very slowly to the point it cannot be used. Is there a way I can speed up the controller to make it run in real time? Should I be exported the code to C++ then tuning my model parameters from there? I know that this is very vague question, I apperate any help.I am trying to build a controller in simulink to interact with ROS and custom simulation of my robot. The controller is rather complex, and involves communication with several topics.
When I try to publish the setpoints to the controller the controller runs very slowly to the point it cannot be used. Is there a way I can speed up the controller to make it run in real time? Should I be exported the code to C++ then tuning my model parameters from there? I know that this is very vague question, I apperate any help. I am trying to build a controller in simulink to interact with ROS and custom simulation of my robot. The controller is rather complex, and involves communication with several topics.
When I try to publish the setpoints to the controller the controller runs very slowly to the point it cannot be used. Is there a way I can speed up the controller to make it run in real time? Should I be exported the code to C++ then tuning my model parameters from there? I know that this is very vague question, I apperate any help. ros, simulink MATLAB Answers — New Questions
AUTOSAR Code Generation Error in 2023b
Hi,
I have question because there is an error during the generation of the AUTOSAR Code
That Error comes from my laptop,
Below is the contents of the errorHi,
I have question because there is an error during the generation of the AUTOSAR Code
That Error comes from my laptop,
Below is the contents of the error Hi,
I have question because there is an error during the generation of the AUTOSAR Code
That Error comes from my laptop,
Below is the contents of the error autosar code generation, simulink MATLAB Answers — New Questions
How to Fix “Warning: Colon operands must be real scalars” Warning
When I run the code below, it works as I wanted, but I get a warning. I tried different things to fix it, but of no avail. How can I refactor my code so that I will not face any related issue as the warning states if I can?
ply_nums_range = [4, 8, 16, 32, 64];
x = rand(1, 2);
data = cartesian_product({b_range, …
N_xx_range, …
N_yy_range, …
N_xy_range, …
ang_range});
for e = ply_nums_range
ply_nums = e;
for i = 1:length(data)
b = data(i, 1);
N_xx = data(i, 2);
N_yy = data(i, 3);
N_xy = data(i, 4);
ang = data(i, 5);
iteration = [a, …
b, …
N_xx, …
N_yy, …
N_xy, …
[PLY_ANGS(ang, x), flip(PLY_ANGS(ang, x))]];
thetas = cell(1, ply_nums);
for j = 1:ply_nums
thetas{j} = sprintf("theta_%d", j);
end
variable_names = ["a", "b", "N_xx", "N_yy", "N_xy", thetas];
table_data = array2table(iteration, …
‘VariableNames’, …
variable_names);
sheet_name = sprintf("%d_ply_case", e);
writetable(table_data, …
"design-cases/case.xlsx", …
‘WriteMode’, ‘Append’, …
‘Sheet’, sheet_name);
end
end
Console output:
Warning: Colon operands must be real scalars. This warning will become an error in a future release.
> In matlab.io.spreadsheet.internal.write.writeXLSFile>getRangeToWrite (line 575)
In matlab.io.spreadsheet.internal.write.writeXLSFile (line 262)
In writetable (line 426)
In test_case (line 72)When I run the code below, it works as I wanted, but I get a warning. I tried different things to fix it, but of no avail. How can I refactor my code so that I will not face any related issue as the warning states if I can?
ply_nums_range = [4, 8, 16, 32, 64];
x = rand(1, 2);
data = cartesian_product({b_range, …
N_xx_range, …
N_yy_range, …
N_xy_range, …
ang_range});
for e = ply_nums_range
ply_nums = e;
for i = 1:length(data)
b = data(i, 1);
N_xx = data(i, 2);
N_yy = data(i, 3);
N_xy = data(i, 4);
ang = data(i, 5);
iteration = [a, …
b, …
N_xx, …
N_yy, …
N_xy, …
[PLY_ANGS(ang, x), flip(PLY_ANGS(ang, x))]];
thetas = cell(1, ply_nums);
for j = 1:ply_nums
thetas{j} = sprintf("theta_%d", j);
end
variable_names = ["a", "b", "N_xx", "N_yy", "N_xy", thetas];
table_data = array2table(iteration, …
‘VariableNames’, …
variable_names);
sheet_name = sprintf("%d_ply_case", e);
writetable(table_data, …
"design-cases/case.xlsx", …
‘WriteMode’, ‘Append’, …
‘Sheet’, sheet_name);
end
end
Console output:
Warning: Colon operands must be real scalars. This warning will become an error in a future release.
> In matlab.io.spreadsheet.internal.write.writeXLSFile>getRangeToWrite (line 575)
In matlab.io.spreadsheet.internal.write.writeXLSFile (line 262)
In writetable (line 426)
In test_case (line 72) When I run the code below, it works as I wanted, but I get a warning. I tried different things to fix it, but of no avail. How can I refactor my code so that I will not face any related issue as the warning states if I can?
ply_nums_range = [4, 8, 16, 32, 64];
x = rand(1, 2);
data = cartesian_product({b_range, …
N_xx_range, …
N_yy_range, …
N_xy_range, …
ang_range});
for e = ply_nums_range
ply_nums = e;
for i = 1:length(data)
b = data(i, 1);
N_xx = data(i, 2);
N_yy = data(i, 3);
N_xy = data(i, 4);
ang = data(i, 5);
iteration = [a, …
b, …
N_xx, …
N_yy, …
N_xy, …
[PLY_ANGS(ang, x), flip(PLY_ANGS(ang, x))]];
thetas = cell(1, ply_nums);
for j = 1:ply_nums
thetas{j} = sprintf("theta_%d", j);
end
variable_names = ["a", "b", "N_xx", "N_yy", "N_xy", thetas];
table_data = array2table(iteration, …
‘VariableNames’, …
variable_names);
sheet_name = sprintf("%d_ply_case", e);
writetable(table_data, …
"design-cases/case.xlsx", …
‘WriteMode’, ‘Append’, …
‘Sheet’, sheet_name);
end
end
Console output:
Warning: Colon operands must be real scalars. This warning will become an error in a future release.
> In matlab.io.spreadsheet.internal.write.writeXLSFile>getRangeToWrite (line 575)
In matlab.io.spreadsheet.internal.write.writeXLSFile (line 262)
In writetable (line 426)
In test_case (line 72) cell, array, table MATLAB Answers — New Questions
How to convert image into matrix
Dear readers, i am new to matlab and want to learn how to convert or represent a picture in bmp or jpeg format in matrix form so that manipulations can be carried out on it.
your suggestions will be worth for me..
suyash bhardwajDear readers, i am new to matlab and want to learn how to convert or represent a picture in bmp or jpeg format in matrix form so that manipulations can be carried out on it.
your suggestions will be worth for me..
suyash bhardwaj Dear readers, i am new to matlab and want to learn how to convert or represent a picture in bmp or jpeg format in matrix form so that manipulations can be carried out on it.
your suggestions will be worth for me..
suyash bhardwaj image processing MATLAB Answers — New Questions
Why do I receive “Products Already Installed” when installing MathWorks products?
Why do I receive "Products Already Installed" when installing MathWorks products?Why do I receive "Products Already Installed" when installing MathWorks products? Why do I receive "Products Already Installed" when installing MathWorks products? why do i receive "products already installed" when MATLAB Answers — New Questions
removing quotes from table
Hi,
I have a table with gregorian time that loads as having single quotes around it. This is giving me issues when I want to do table2timetable.
How do I remove the quotes so I can convert to timetable?
Thanks!Hi,
I have a table with gregorian time that loads as having single quotes around it. This is giving me issues when I want to do table2timetable.
How do I remove the quotes so I can convert to timetable?
Thanks! Hi,
I have a table with gregorian time that loads as having single quotes around it. This is giving me issues when I want to do table2timetable.
How do I remove the quotes so I can convert to timetable?
Thanks! removing quotes, timetable MATLAB Answers — New Questions
Warning: Not enough data imported. Attempt to read… (Dicominfo/Dicomdisp)
Hello,
I would like to ask how to solve this issue in matlab, while I am trying to read several dicom images I have got from PACS. Radiant application shows images normally, but Matlab does not recognise the size of them, width and height, and I am getting this warning as well, when i call dicominfo:
The second number of bytes (only read) is the actual size of my picture(.dcm), and however, Matlab attempts to read like 1,3Gb of data, instead the actual size of it which is 12Mb.
Also, when i use dicomdisp i get the following:
I have highlighted where i find the actual size, in that private attribute, and also noticed how there is no location 6182 (it ends at 6170), and there are some more attributes which their size is like 4.3 Gb. Is reading it on IEEE little-endian machine related with my computer or PACS? Could that be the reason? Widh and Height attributes are both in dicomdisp and Radiant (Dicom Viewer Application) shown as WindowWidth/WindowCenter and WL/WW respectively. Therefore, it could be some sort of incompatibility between headers/attributes from one source to another?
Is it something to do with their actual size of my dicom pictures, which is rather too much for my laptop to handle? They are 2k x 4k resolution. So, since my screen doesnt support that resolution, maybe that’s why Matlab open just a blank figure? Still, shouldnt it have been able to read width and height with dicominfo?
In addition to that, in line (63) at dicominfo.m describes some issues about parsing the dicom file and its attributes, but I am not sure if it is related with the previous issue.
Any help would be grateful.Hello,
I would like to ask how to solve this issue in matlab, while I am trying to read several dicom images I have got from PACS. Radiant application shows images normally, but Matlab does not recognise the size of them, width and height, and I am getting this warning as well, when i call dicominfo:
The second number of bytes (only read) is the actual size of my picture(.dcm), and however, Matlab attempts to read like 1,3Gb of data, instead the actual size of it which is 12Mb.
Also, when i use dicomdisp i get the following:
I have highlighted where i find the actual size, in that private attribute, and also noticed how there is no location 6182 (it ends at 6170), and there are some more attributes which their size is like 4.3 Gb. Is reading it on IEEE little-endian machine related with my computer or PACS? Could that be the reason? Widh and Height attributes are both in dicomdisp and Radiant (Dicom Viewer Application) shown as WindowWidth/WindowCenter and WL/WW respectively. Therefore, it could be some sort of incompatibility between headers/attributes from one source to another?
Is it something to do with their actual size of my dicom pictures, which is rather too much for my laptop to handle? They are 2k x 4k resolution. So, since my screen doesnt support that resolution, maybe that’s why Matlab open just a blank figure? Still, shouldnt it have been able to read width and height with dicominfo?
In addition to that, in line (63) at dicominfo.m describes some issues about parsing the dicom file and its attributes, but I am not sure if it is related with the previous issue.
Any help would be grateful. Hello,
I would like to ask how to solve this issue in matlab, while I am trying to read several dicom images I have got from PACS. Radiant application shows images normally, but Matlab does not recognise the size of them, width and height, and I am getting this warning as well, when i call dicominfo:
The second number of bytes (only read) is the actual size of my picture(.dcm), and however, Matlab attempts to read like 1,3Gb of data, instead the actual size of it which is 12Mb.
Also, when i use dicomdisp i get the following:
I have highlighted where i find the actual size, in that private attribute, and also noticed how there is no location 6182 (it ends at 6170), and there are some more attributes which their size is like 4.3 Gb. Is reading it on IEEE little-endian machine related with my computer or PACS? Could that be the reason? Widh and Height attributes are both in dicomdisp and Radiant (Dicom Viewer Application) shown as WindowWidth/WindowCenter and WL/WW respectively. Therefore, it could be some sort of incompatibility between headers/attributes from one source to another?
Is it something to do with their actual size of my dicom pictures, which is rather too much for my laptop to handle? They are 2k x 4k resolution. So, since my screen doesnt support that resolution, maybe that’s why Matlab open just a blank figure? Still, shouldnt it have been able to read width and height with dicominfo?
In addition to that, in line (63) at dicominfo.m describes some issues about parsing the dicom file and its attributes, but I am not sure if it is related with the previous issue.
Any help would be grateful. dicominfo MATLAB Answers — New Questions
error in concatenating cells
Hello Dear,
I have 1×50 cell (ftData728178E.trial) in a struct. Each cell has a 192×2301 double. After I concatenate the cell to make a matrix of 192x2301x50, the matrix turns into nan. I wonder why it is and what the correct way to turn cells into a matrix. Thanks,
ET
ft_epoch = cat(3, ftData728178E.trial{:});Hello Dear,
I have 1×50 cell (ftData728178E.trial) in a struct. Each cell has a 192×2301 double. After I concatenate the cell to make a matrix of 192x2301x50, the matrix turns into nan. I wonder why it is and what the correct way to turn cells into a matrix. Thanks,
ET
ft_epoch = cat(3, ftData728178E.trial{:}); Hello Dear,
I have 1×50 cell (ftData728178E.trial) in a struct. Each cell has a 192×2301 double. After I concatenate the cell to make a matrix of 192x2301x50, the matrix turns into nan. I wonder why it is and what the correct way to turn cells into a matrix. Thanks,
ET
ft_epoch = cat(3, ftData728178E.trial{:}); cell, concatention, matrix MATLAB Answers — New Questions
Setting common color maps for categorical images with no ordinal information in the categorical labels
I’m trying to create a common colormap from two different categorical images that are segmentations of brain regions. The labels in "oldsegvis" are an entirely contained subset of the labels in "newsegvis". I’m expecting the same label value (e.g. newseg = 100, oldseg = 100) to return the same color, however, that is not the output behavior I’m observing. I’ve confirmed by looking at the values in the output newsegvis and oldsegvis arrays and by using "Data Tips" that the same values are being assigned different colors. Additionally, in the visualization of the "newsegvis" array, different values are being assigned the same color, which I’ve also confirmed with "Data Tips", even though the number of colors and the number of unique label values are the same. A code snippet is pasted below; I’m sure there’s something simple I’m missing, but would be very appreciative if someone could point it out to me. Thanks!
%% Visualize segmentations
%select section (transverse plane)
newsegvis = squeeze(newvol(:,:,100));
oldsegvis = squeeze(oldvol(:,:,100));
%set colormaps (new segmentations have all old segmentation labels plus
%additional labels)
newsegs = unique(newsegvis);
oldsegs = unique(oldsegvis);
cmap_ov = [0 0 0;rand(length(newsegs)-1,3)];
cmap_orig = cmap_ov(1:length(oldsegs),:);
%visualize segmentations
figure; imagesc(newsegvis); colormap(cmap_ov);
figure; imagesc(oldsegvis); colormap(cmap_orig);I’m trying to create a common colormap from two different categorical images that are segmentations of brain regions. The labels in "oldsegvis" are an entirely contained subset of the labels in "newsegvis". I’m expecting the same label value (e.g. newseg = 100, oldseg = 100) to return the same color, however, that is not the output behavior I’m observing. I’ve confirmed by looking at the values in the output newsegvis and oldsegvis arrays and by using "Data Tips" that the same values are being assigned different colors. Additionally, in the visualization of the "newsegvis" array, different values are being assigned the same color, which I’ve also confirmed with "Data Tips", even though the number of colors and the number of unique label values are the same. A code snippet is pasted below; I’m sure there’s something simple I’m missing, but would be very appreciative if someone could point it out to me. Thanks!
%% Visualize segmentations
%select section (transverse plane)
newsegvis = squeeze(newvol(:,:,100));
oldsegvis = squeeze(oldvol(:,:,100));
%set colormaps (new segmentations have all old segmentation labels plus
%additional labels)
newsegs = unique(newsegvis);
oldsegs = unique(oldsegvis);
cmap_ov = [0 0 0;rand(length(newsegs)-1,3)];
cmap_orig = cmap_ov(1:length(oldsegs),:);
%visualize segmentations
figure; imagesc(newsegvis); colormap(cmap_ov);
figure; imagesc(oldsegvis); colormap(cmap_orig); I’m trying to create a common colormap from two different categorical images that are segmentations of brain regions. The labels in "oldsegvis" are an entirely contained subset of the labels in "newsegvis". I’m expecting the same label value (e.g. newseg = 100, oldseg = 100) to return the same color, however, that is not the output behavior I’m observing. I’ve confirmed by looking at the values in the output newsegvis and oldsegvis arrays and by using "Data Tips" that the same values are being assigned different colors. Additionally, in the visualization of the "newsegvis" array, different values are being assigned the same color, which I’ve also confirmed with "Data Tips", even though the number of colors and the number of unique label values are the same. A code snippet is pasted below; I’m sure there’s something simple I’m missing, but would be very appreciative if someone could point it out to me. Thanks!
%% Visualize segmentations
%select section (transverse plane)
newsegvis = squeeze(newvol(:,:,100));
oldsegvis = squeeze(oldvol(:,:,100));
%set colormaps (new segmentations have all old segmentation labels plus
%additional labels)
newsegs = unique(newsegvis);
oldsegs = unique(oldsegvis);
cmap_ov = [0 0 0;rand(length(newsegs)-1,3)];
cmap_orig = cmap_ov(1:length(oldsegs),:);
%visualize segmentations
figure; imagesc(newsegvis); colormap(cmap_ov);
figure; imagesc(oldsegvis); colormap(cmap_orig); colormap, imagesc MATLAB Answers — New Questions
Support for NVIDIA RTX A1000
I am evaluating if a Dell laptop with an NVIDIA RTX A1000 graphics card can take advantage of the GPU accleration in Matlab. The NVIDIA site does not list the ‘compute capability’ of the RTX A1000 in the table of current or legacy graphic cards.I am evaluating if a Dell laptop with an NVIDIA RTX A1000 graphics card can take advantage of the GPU accleration in Matlab. The NVIDIA site does not list the ‘compute capability’ of the RTX A1000 in the table of current or legacy graphic cards. I am evaluating if a Dell laptop with an NVIDIA RTX A1000 graphics card can take advantage of the GPU accleration in Matlab. The NVIDIA site does not list the ‘compute capability’ of the RTX A1000 in the table of current or legacy graphic cards. nvidia rtx a1000 MATLAB Answers — New Questions
What does it mean “/Multiple” after variable name in *.mat file?
I have *.mat files exported by Bruker Opus program. When I select these files Matlab lists the variables contained in that file. However, after each variable name there is a /Multiple note, (see figure).
When I click on the file it does not load anything.
What does it mean the "/Multiple"? How to load these files?I have *.mat files exported by Bruker Opus program. When I select these files Matlab lists the variables contained in that file. However, after each variable name there is a /Multiple note, (see figure).
When I click on the file it does not load anything.
What does it mean the "/Multiple"? How to load these files? I have *.mat files exported by Bruker Opus program. When I select these files Matlab lists the variables contained in that file. However, after each variable name there is a /Multiple note, (see figure).
When I click on the file it does not load anything.
What does it mean the "/Multiple"? How to load these files? bruker, opus, mat files, /multiple flag? MATLAB Answers — New Questions