Tag Archives: matlab
Why can’t i suppress the simulink warning Simulink:protectedModel:protectedModelMexWrongPlatformSimCodeGenWithWebview?
I wonder why i am not able to suppress the following simulink warning:
–> Simulink:protectedModel:protectedModelMexWrongPlatformSimCodeGenWithWebview
Simulink.suppressDiagnostic(gcb,’Simulink:protectedModel:protectedModelMexWrongPlatformSimCodeGenWithWebview’)
With this i got the following response in commandline:
"The message identifier Simulink:protectedModel:protectedModelMexWrongPlatformSimCodeGenWithWebview cannot be suppressed."
Is there another way to hide or suppress this warning or are there limitations on suppressable warnings?I wonder why i am not able to suppress the following simulink warning:
–> Simulink:protectedModel:protectedModelMexWrongPlatformSimCodeGenWithWebview
Simulink.suppressDiagnostic(gcb,’Simulink:protectedModel:protectedModelMexWrongPlatformSimCodeGenWithWebview’)
With this i got the following response in commandline:
"The message identifier Simulink:protectedModel:protectedModelMexWrongPlatformSimCodeGenWithWebview cannot be suppressed."
Is there another way to hide or suppress this warning or are there limitations on suppressable warnings? I wonder why i am not able to suppress the following simulink warning:
–> Simulink:protectedModel:protectedModelMexWrongPlatformSimCodeGenWithWebview
Simulink.suppressDiagnostic(gcb,’Simulink:protectedModel:protectedModelMexWrongPlatformSimCodeGenWithWebview’)
With this i got the following response in commandline:
"The message identifier Simulink:protectedModel:protectedModelMexWrongPlatformSimCodeGenWithWebview cannot be suppressed."
Is there another way to hide or suppress this warning or are there limitations on suppressable warnings? warnings, diagnostics MATLAB Answers — New Questions
Can deployed model run at MHz frequency on Arduino Mega 2560?
While exploring the "Getting Started with Arduino Hardware" example, I would like to be able to generate a repeating pulse with a width of 5 us. When I attempt to do this with the "arduino_gettingstarted.SLX" file and my Arduino Mega 2560, I noticed on my oscilloscope that the pulse width was not what I defined it to be.
Is it possible to generate pulses at or around 5 us?While exploring the "Getting Started with Arduino Hardware" example, I would like to be able to generate a repeating pulse with a width of 5 us. When I attempt to do this with the "arduino_gettingstarted.SLX" file and my Arduino Mega 2560, I noticed on my oscilloscope that the pulse width was not what I defined it to be.
Is it possible to generate pulses at or around 5 us? While exploring the "Getting Started with Arduino Hardware" example, I would like to be able to generate a repeating pulse with a width of 5 us. When I attempt to do this with the "arduino_gettingstarted.SLX" file and my Arduino Mega 2560, I noticed on my oscilloscope that the pulse width was not what I defined it to be.
Is it possible to generate pulses at or around 5 us? arduino, mega, 2560, frequency, pulse, generator MATLAB Answers — New Questions
Somethings wrong in function mskmod
in annotation,”Pulse shape by cos((pi*t/2T)+pi/2)”
but in code,y = complex(xI.*cos(arg+pi), xQ.*sin(arg)) .* exp(1i*ini_phase); is cos(arg+pi),why not cos(arg+pi/2),and why need plus pi or pi/2in annotation,”Pulse shape by cos((pi*t/2T)+pi/2)”
but in code,y = complex(xI.*cos(arg+pi), xQ.*sin(arg)) .* exp(1i*ini_phase); is cos(arg+pi),why not cos(arg+pi/2),and why need plus pi or pi/2 in annotation,”Pulse shape by cos((pi*t/2T)+pi/2)”
but in code,y = complex(xI.*cos(arg+pi), xQ.*sin(arg)) .* exp(1i*ini_phase); is cos(arg+pi),why not cos(arg+pi/2),and why need plus pi or pi/2 mskmod, digital signal processing, 通信 MATLAB Answers — New Questions
How to use fminunc for a 2D function composed of two functions?
I have:
and I want to minimize it on the unit square without using differentials.
I use the following code,
close all; clear; clc;
options = optimoptions(@fminunc,’Display’,’iter’,’Algorithm’,’quasi-newton’);
xy_guess = [0,0];
[xy_opt,fval] = fminunc(@quadratic,xy_guess,options)
function f = quadratic(in)
x = in(1);
y = in(2);
f = -5.*x – 5.*y + 10.*x.^2 + 2.*x.*y
f = 1/200.*(-1000.*x – 1000.*y + 400.*x.*y + 1200.*y.^2 + 5.*cos(30.*x) + 4.*cos(80.*x.^2) + 5.*cos(30.*y) + 4.*cos(80.*y^2))
But declaring f twice does not work. How should I declare this double-function as an input for fminunc ?
Thanks!I have:
and I want to minimize it on the unit square without using differentials.
I use the following code,
close all; clear; clc;
options = optimoptions(@fminunc,’Display’,’iter’,’Algorithm’,’quasi-newton’);
xy_guess = [0,0];
[xy_opt,fval] = fminunc(@quadratic,xy_guess,options)
function f = quadratic(in)
x = in(1);
y = in(2);
f = -5.*x – 5.*y + 10.*x.^2 + 2.*x.*y
f = 1/200.*(-1000.*x – 1000.*y + 400.*x.*y + 1200.*y.^2 + 5.*cos(30.*x) + 4.*cos(80.*x.^2) + 5.*cos(30.*y) + 4.*cos(80.*y^2))
But declaring f twice does not work. How should I declare this double-function as an input for fminunc ?
Thanks! I have:
and I want to minimize it on the unit square without using differentials.
I use the following code,
close all; clear; clc;
options = optimoptions(@fminunc,’Display’,’iter’,’Algorithm’,’quasi-newton’);
xy_guess = [0,0];
[xy_opt,fval] = fminunc(@quadratic,xy_guess,options)
function f = quadratic(in)
x = in(1);
y = in(2);
f = -5.*x – 5.*y + 10.*x.^2 + 2.*x.*y
f = 1/200.*(-1000.*x – 1000.*y + 400.*x.*y + 1200.*y.^2 + 5.*cos(30.*x) + 4.*cos(80.*x.^2) + 5.*cos(30.*y) + 4.*cos(80.*y^2))
But declaring f twice does not work. How should I declare this double-function as an input for fminunc ?
Thanks! fminunc, declare, function MATLAB Answers — New Questions
Connecting branch points using a straight line as dictated by the skeleton
I want to connect the branch points and endpoints of a skeleton (see sample skeleton below) via straight lines. However, the lines should be along the path of the skeleton. It’s like "straightening" the skeleton. I’ve drawn a sample picture below describing how the branchpoints should be connected by the blue straight lines.
I’m thinking that this would probably involve a traversal algorithm.I want to connect the branch points and endpoints of a skeleton (see sample skeleton below) via straight lines. However, the lines should be along the path of the skeleton. It’s like "straightening" the skeleton. I’ve drawn a sample picture below describing how the branchpoints should be connected by the blue straight lines.
I’m thinking that this would probably involve a traversal algorithm. I want to connect the branch points and endpoints of a skeleton (see sample skeleton below) via straight lines. However, the lines should be along the path of the skeleton. It’s like "straightening" the skeleton. I’ve drawn a sample picture below describing how the branchpoints should be connected by the blue straight lines.
I’m thinking that this would probably involve a traversal algorithm. skeleton, image analysis, image processing MATLAB Answers — New Questions
Why am getting decline in Active Receptor graph even the Relative Ligand Concentration is Constant. Kindly help me out to sort out this issue. I shared the MatLab script
getting decline in Active Receptor graph even the Relative Ligand Concentration is Constant. Kindly help me out to sort out this issue. I shared the MatLab script and GUI file and screen shot of graph.getting decline in Active Receptor graph even the Relative Ligand Concentration is Constant. Kindly help me out to sort out this issue. I shared the MatLab script and GUI file and screen shot of graph. getting decline in Active Receptor graph even the Relative Ligand Concentration is Constant. Kindly help me out to sort out this issue. I shared the MatLab script and GUI file and screen shot of graph. matlab MATLAB Answers — New Questions
Change coordinate system, from EPSG 3003 to EPSG 32632 (i.e. WGS 84 / UTM zone 32N)
I have the following point with x-y-coordinates in the EPSG 3003 coordinate system:
a = [1.7202e+06 4.8998e+06]
How can change the above mentioned x-y-coordinates from EPSG 3003 to EPSG:32632 (i.e. WGS 84 / UTM zone 32N)?I have the following point with x-y-coordinates in the EPSG 3003 coordinate system:
a = [1.7202e+06 4.8998e+06]
How can change the above mentioned x-y-coordinates from EPSG 3003 to EPSG:32632 (i.e. WGS 84 / UTM zone 32N)? I have the following point with x-y-coordinates in the EPSG 3003 coordinate system:
a = [1.7202e+06 4.8998e+06]
How can change the above mentioned x-y-coordinates from EPSG 3003 to EPSG:32632 (i.e. WGS 84 / UTM zone 32N)? coordinate, projection, epsg, wgs84 MATLAB Answers — New Questions
Reinforcement Learning on Simscape
I am having an issue with RL in simscape. I added a unit delay in order to break an algrbraic loop but what the unit delay initial condition does it that it sets the value I want to change to a constant equal to the initial condition of the unit delay bloc. Do you by any chance know what might be the problem causing this ?
I will add a screenshot of the training.I am having an issue with RL in simscape. I added a unit delay in order to break an algrbraic loop but what the unit delay initial condition does it that it sets the value I want to change to a constant equal to the initial condition of the unit delay bloc. Do you by any chance know what might be the problem causing this ?
I will add a screenshot of the training. I am having an issue with RL in simscape. I added a unit delay in order to break an algrbraic loop but what the unit delay initial condition does it that it sets the value I want to change to a constant equal to the initial condition of the unit delay bloc. Do you by any chance know what might be the problem causing this ?
I will add a screenshot of the training. reinforcement learning, simscape, simulation, programming MATLAB Answers — New Questions
How can I make such that every method call to a class is routed through a wrapper
Is there a way to automatically wrap every method call to a class in a wrapper function in MATLAB? For example, suppose I have a class with methods method1 and method2 and a wrapper function wrapper_func. The wrapper_func should:
Print the inputs and the name of the method.
Call the actual method (e.g., method1).
Print the outputs of the method.
When I create an object obj of this class and call obj.method1, it should implicitly call wrapper_func with method1 so that the wrapper function handles the input/output printing and method execution. How can this be achieved in MATLAB?Is there a way to automatically wrap every method call to a class in a wrapper function in MATLAB? For example, suppose I have a class with methods method1 and method2 and a wrapper function wrapper_func. The wrapper_func should:
Print the inputs and the name of the method.
Call the actual method (e.g., method1).
Print the outputs of the method.
When I create an object obj of this class and call obj.method1, it should implicitly call wrapper_func with method1 so that the wrapper function handles the input/output printing and method execution. How can this be achieved in MATLAB? Is there a way to automatically wrap every method call to a class in a wrapper function in MATLAB? For example, suppose I have a class with methods method1 and method2 and a wrapper function wrapper_func. The wrapper_func should:
Print the inputs and the name of the method.
Call the actual method (e.g., method1).
Print the outputs of the method.
When I create an object obj of this class and call obj.method1, it should implicitly call wrapper_func with method1 so that the wrapper function handles the input/output printing and method execution. How can this be achieved in MATLAB? wrapper, class MATLAB Answers — New Questions
Reinforcement learning with Simulink and Simscape
Hi,
improving control of physical systems with Reinforcement learning is tempting and might lead to real improvements.
If we considere a physical domain like Thermal for example, reinforcement learning would require to build a model to achieve offline training.
Are there limitations that would prevent the use of Simulink+Simscape to do this (algebraic loop issues for example)?
BR
DavidHi,
improving control of physical systems with Reinforcement learning is tempting and might lead to real improvements.
If we considere a physical domain like Thermal for example, reinforcement learning would require to build a model to achieve offline training.
Are there limitations that would prevent the use of Simulink+Simscape to do this (algebraic loop issues for example)?
BR
David Hi,
improving control of physical systems with Reinforcement learning is tempting and might lead to real improvements.
If we considere a physical domain like Thermal for example, reinforcement learning would require to build a model to achieve offline training.
Are there limitations that would prevent the use of Simulink+Simscape to do this (algebraic loop issues for example)?
BR
David reinforcement learning simscape MATLAB Answers — New Questions
How to design your own input signal characteristics in Simulink?
While Designing Active noise cancellation algorithm in simulink, generally white noise or pink noise is used, however if the source of noise is from cetrain plane with specific dB at defined frequency in frequency band from 50Hz to 10KHz. How to design source noise signal in simulink. Or do I need to intergate the simulink model to hardware system in real time?While Designing Active noise cancellation algorithm in simulink, generally white noise or pink noise is used, however if the source of noise is from cetrain plane with specific dB at defined frequency in frequency band from 50Hz to 10KHz. How to design source noise signal in simulink. Or do I need to intergate the simulink model to hardware system in real time? While Designing Active noise cancellation algorithm in simulink, generally white noise or pink noise is used, however if the source of noise is from cetrain plane with specific dB at defined frequency in frequency band from 50Hz to 10KHz. How to design source noise signal in simulink. Or do I need to intergate the simulink model to hardware system in real time? active noise cancellation algorithm, simulink, white noise or pink noise, 50hz to 10khz, design source noise signal, integrating simulink model to real time hardware MATLAB Answers — New Questions
Issues on the translation of MATLAB machine learning model to Python
Dear community,
I had training a Machine Learning model using the classification learner, that as the following characteristics:
% This code specifies all the classifier options and trains the classifier.
template = templateTree(…
‘MaxNumSplits’, 5003);
classificationEnsemble = fitcensemble(…
predictors, …
response, …
‘Method’, ‘Bag’, …
‘NumLearningCycles’, 30, …
‘Learners’, template, …
‘ClassNames’, [1; 2; 3; 4; 5]);
I managed to get an accuracy of around 98%.
But when I tried to translate this code to Python, as follows and with the same training set, but I am not able to find the same accuracy, its a lot lower in Python. I would like to know if and what are the differences between both languages so I can adjust the parameters accordingly.
template = templateTree(…
‘MaxNumSplits’, 5003);
classificationEnsemble = fitcensemble(…
predictors, …
response, …
‘Method’, ‘Bag’, …
‘NumLearningCycles’, 30, …
‘Learners’, template, …
‘ClassNames’, [1; 2; 3; 4; 5]);
Thank you in advance.Dear community,
I had training a Machine Learning model using the classification learner, that as the following characteristics:
% This code specifies all the classifier options and trains the classifier.
template = templateTree(…
‘MaxNumSplits’, 5003);
classificationEnsemble = fitcensemble(…
predictors, …
response, …
‘Method’, ‘Bag’, …
‘NumLearningCycles’, 30, …
‘Learners’, template, …
‘ClassNames’, [1; 2; 3; 4; 5]);
I managed to get an accuracy of around 98%.
But when I tried to translate this code to Python, as follows and with the same training set, but I am not able to find the same accuracy, its a lot lower in Python. I would like to know if and what are the differences between both languages so I can adjust the parameters accordingly.
template = templateTree(…
‘MaxNumSplits’, 5003);
classificationEnsemble = fitcensemble(…
predictors, …
response, …
‘Method’, ‘Bag’, …
‘NumLearningCycles’, 30, …
‘Learners’, template, …
‘ClassNames’, [1; 2; 3; 4; 5]);
Thank you in advance. Dear community,
I had training a Machine Learning model using the classification learner, that as the following characteristics:
% This code specifies all the classifier options and trains the classifier.
template = templateTree(…
‘MaxNumSplits’, 5003);
classificationEnsemble = fitcensemble(…
predictors, …
response, …
‘Method’, ‘Bag’, …
‘NumLearningCycles’, 30, …
‘Learners’, template, …
‘ClassNames’, [1; 2; 3; 4; 5]);
I managed to get an accuracy of around 98%.
But when I tried to translate this code to Python, as follows and with the same training set, but I am not able to find the same accuracy, its a lot lower in Python. I would like to know if and what are the differences between both languages so I can adjust the parameters accordingly.
template = templateTree(…
‘MaxNumSplits’, 5003);
classificationEnsemble = fitcensemble(…
predictors, …
response, …
‘Method’, ‘Bag’, …
‘NumLearningCycles’, 30, …
‘Learners’, template, …
‘ClassNames’, [1; 2; 3; 4; 5]);
Thank you in advance. machine learning, classification learner, python, ensemble MATLAB Answers — New Questions
access data in App-Designer in nested function call
I have defined a variable cr as a public propertie and can refer to it within the program by usind app.cr. However I call a function withinh function
where I need to use the variable, but by running the programm I get an error message:
Unrecognized field name "cr".
Error in SolarsystemOrbits_03/EarthOrbit (line 413)
app.TMG_solver( n, x, y, z, vx, vy, vz, bx, by, bz);
Error in SolarsystemOrbits_03/OrbitMain (line 191)
app.EarthOrbit;
Error in SolarsystemOrbits_03/ComputeButtonPushed (line 1341)
app.OrbitMain;
What am I doing wrong.I have defined a variable cr as a public propertie and can refer to it within the program by usind app.cr. However I call a function withinh function
where I need to use the variable, but by running the programm I get an error message:
Unrecognized field name "cr".
Error in SolarsystemOrbits_03/EarthOrbit (line 413)
app.TMG_solver( n, x, y, z, vx, vy, vz, bx, by, bz);
Error in SolarsystemOrbits_03/OrbitMain (line 191)
app.EarthOrbit;
Error in SolarsystemOrbits_03/ComputeButtonPushed (line 1341)
app.OrbitMain;
What am I doing wrong. I have defined a variable cr as a public propertie and can refer to it within the program by usind app.cr. However I call a function withinh function
where I need to use the variable, but by running the programm I get an error message:
Unrecognized field name "cr".
Error in SolarsystemOrbits_03/EarthOrbit (line 413)
app.TMG_solver( n, x, y, z, vx, vy, vz, bx, by, bz);
Error in SolarsystemOrbits_03/OrbitMain (line 191)
app.EarthOrbit;
Error in SolarsystemOrbits_03/ComputeButtonPushed (line 1341)
app.OrbitMain;
What am I doing wrong. data in app designer MATLAB Answers — New Questions
Linear Inversion of River Profiles
Has any one tried the code by Sean.F.Gallen on linear inversion of river profiles.
https://github.com/sfgallen/Block_Uplift_Linear_Inversion_Models.
If anybody has tried may please help me as I am finding difficulty in running the code.Has any one tried the code by Sean.F.Gallen on linear inversion of river profiles.
https://github.com/sfgallen/Block_Uplift_Linear_Inversion_Models.
If anybody has tried may please help me as I am finding difficulty in running the code. Has any one tried the code by Sean.F.Gallen on linear inversion of river profiles.
https://github.com/sfgallen/Block_Uplift_Linear_Inversion_Models.
If anybody has tried may please help me as I am finding difficulty in running the code. topotoolbox, plotting MATLAB Answers — New Questions
Plotting a 3-value graph
Hı,
How can I draw the graph whose image I added? can you help me please?
The relationship between values is briefly,
drift ratio – displacement
displacement – base shear
I use the hold on command, but displacement and drift ratio are on the same axis (x axis).
How can I define separate axis like here?Hı,
How can I draw the graph whose image I added? can you help me please?
The relationship between values is briefly,
drift ratio – displacement
displacement – base shear
I use the hold on command, but displacement and drift ratio are on the same axis (x axis).
How can I define separate axis like here? Hı,
How can I draw the graph whose image I added? can you help me please?
The relationship between values is briefly,
drift ratio – displacement
displacement – base shear
I use the hold on command, but displacement and drift ratio are on the same axis (x axis).
How can I define separate axis like here? graphics, matlab MATLAB Answers — New Questions
Error using readgeoraster??
file1 = ‘path/to/first/raster.tif’;
file2 = ‘path/to/second/raster.tif’;
file3 = ‘path/to/third/raster.tif’;
raster1 = readgeoraster(file1);
I try to file upload and slope analysis but ı got this error. Can you help me with this prob?file1 = ‘path/to/first/raster.tif’;
file2 = ‘path/to/second/raster.tif’;
file3 = ‘path/to/third/raster.tif’;
raster1 = readgeoraster(file1);
I try to file upload and slope analysis but ı got this error. Can you help me with this prob? file1 = ‘path/to/first/raster.tif’;
file2 = ‘path/to/second/raster.tif’;
file3 = ‘path/to/third/raster.tif’;
raster1 = readgeoraster(file1);
I try to file upload and slope analysis but ı got this error. Can you help me with this prob? error, tif, readgeoraster MATLAB Answers — New Questions
Share content from Matlab cloud drive
Hello,
is it possible to perform the following actions from matlab command prompt?
Create a folder in Matlab Drive
Upload files into the folder
Share the folder
Get the link for sharing
I’d like to get these things done by a script, so I could then just send the sharing link via email
Thanks all,
TeroHello,
is it possible to perform the following actions from matlab command prompt?
Create a folder in Matlab Drive
Upload files into the folder
Share the folder
Get the link for sharing
I’d like to get these things done by a script, so I could then just send the sharing link via email
Thanks all,
Tero Hello,
is it possible to perform the following actions from matlab command prompt?
Create a folder in Matlab Drive
Upload files into the folder
Share the folder
Get the link for sharing
I’d like to get these things done by a script, so I could then just send the sharing link via email
Thanks all,
Tero cloud drive, sharing MATLAB Answers — New Questions
varargin error for optional inputs
I was running this code
%%Parse Inputs
p = inputParser;
p.FunctionName = ‘linear_inversion_ksn’;
% required inputs
addRequired(p,’DEM’, @(x) isa(x,’GRIDobj’));
% optional inputs
addOptional(p,’crita’, 1e6, @(x) isscalar(x));
addOptional(p,’mn’, 0.5, @(x) isscalar(x));
addOptional(p,’chi_inc’, 1, @(x) isscalar(x));
addOptional(p,’gam’, 10, @(x) isscalar(x));
addOptional(p,’flowOption’, []);
parse(p,DEM, varargin{:});
DEM = p.Results.DEM;
And got an error like this
>> parse(p,DEM, varargin{:});
Brace indexing into the result of a function call is not supported. Assign the result
of ‘varargin’ to a variable first, then brace index into it.
Kindly help me in fixing itI was running this code
%%Parse Inputs
p = inputParser;
p.FunctionName = ‘linear_inversion_ksn’;
% required inputs
addRequired(p,’DEM’, @(x) isa(x,’GRIDobj’));
% optional inputs
addOptional(p,’crita’, 1e6, @(x) isscalar(x));
addOptional(p,’mn’, 0.5, @(x) isscalar(x));
addOptional(p,’chi_inc’, 1, @(x) isscalar(x));
addOptional(p,’gam’, 10, @(x) isscalar(x));
addOptional(p,’flowOption’, []);
parse(p,DEM, varargin{:});
DEM = p.Results.DEM;
And got an error like this
>> parse(p,DEM, varargin{:});
Brace indexing into the result of a function call is not supported. Assign the result
of ‘varargin’ to a variable first, then brace index into it.
Kindly help me in fixing it I was running this code
%%Parse Inputs
p = inputParser;
p.FunctionName = ‘linear_inversion_ksn’;
% required inputs
addRequired(p,’DEM’, @(x) isa(x,’GRIDobj’));
% optional inputs
addOptional(p,’crita’, 1e6, @(x) isscalar(x));
addOptional(p,’mn’, 0.5, @(x) isscalar(x));
addOptional(p,’chi_inc’, 1, @(x) isscalar(x));
addOptional(p,’gam’, 10, @(x) isscalar(x));
addOptional(p,’flowOption’, []);
parse(p,DEM, varargin{:});
DEM = p.Results.DEM;
And got an error like this
>> parse(p,DEM, varargin{:});
Brace indexing into the result of a function call is not supported. Assign the result
of ‘varargin’ to a variable first, then brace index into it.
Kindly help me in fixing it varargin, function MATLAB Answers — New Questions
Unexpected matlab operator when using Matlab Coder
I use Matlab Coder to generate mex file, but in the middle of process I got error message "Unexpected MATLAB operator" that is indicate ":" in my code
if (abs(permlist(jj,:)-iv))==0
c(jj) = c(jj) + 1 ;
%end
end
Does anyone know how to solve it?I use Matlab Coder to generate mex file, but in the middle of process I got error message "Unexpected MATLAB operator" that is indicate ":" in my code
if (abs(permlist(jj,:)-iv))==0
c(jj) = c(jj) + 1 ;
%end
end
Does anyone know how to solve it? I use Matlab Coder to generate mex file, but in the middle of process I got error message "Unexpected MATLAB operator" that is indicate ":" in my code
if (abs(permlist(jj,:)-iv))==0
c(jj) = c(jj) + 1 ;
%end
end
Does anyone know how to solve it? matlab coder, colon MATLAB Answers — New Questions
the matrix addition should come 0 but it is not happening
i am adding a matrix in for loop
Dtb=zeros(3,3);
Dtrb=Dtb;
Drrb=Dtb;
Dts=zeros(2,2);
for N=1:nlayer
h1=-h/2+(N-1)*th;
h2=h1+th;
ah1=h2-h1;
bh1=(h2^2-h1^2)/2;
ch1=(h2^3-h1^3)/3;
% ———–
if(N <= nlayer/2 || N == 1)
theta=(1+(-1)^N)*pi/4;
else
theta = -1*(-1+(-1)^N)*pi/4;
end
% ————–
theta = rad2deg( theta );
t1=(cosd(theta))^4;
t2=(sind(theta))^4;
t3=(sind(theta)*cosd(theta))^2;
t4=sind(theta)*(cosd(theta))^3;
t5=cosd(theta)*(sind(theta))^3;
%**********************************************************
c111=c11*t1 + 2*(c12+2*c66)*t3 + c22*t2;
c121=(c11 + c22 – 4*c66)*t3 + c12*(t1+t2);
c221=c11*t2 + 2*(c12+2*c66)*t3 + c22*t1;
c161=(c11-c12-2*c66)*t4 + (c12-c22+2*c66)*t5;
c261=(c11-c12-2*c66)*t5 + (c12-c22+2*c66)*t4;
c661=(c11+c22-2*c12-2*c66)*t3 + c66*(t1+t2);
c441=c44*(cos(theta))^2 + c55*(sin(theta))^2;
c451=(c55-c44)*cos(theta)*sin(theta);
c551=c55*(cos(theta))^2 + c44*(sin(theta))^2;
Cb=[c111 c121 c161; c121 c221 c261; c161 c261 c661];
Cs=[c551 c451;c451 c441];
Dtrb = Dtrb + bh1*Cb;
end
but the resulting Dtrb atrix is not coming 0,
as you can see from fig: matrix for iteration 10 is bh1*Cb matrix which is added to Dtrb matrix and in figure both are same but opp in sign so if we add it should come 0 but as you can see in fig the result is not 0 but it is something * e-11 comingi am adding a matrix in for loop
Dtb=zeros(3,3);
Dtrb=Dtb;
Drrb=Dtb;
Dts=zeros(2,2);
for N=1:nlayer
h1=-h/2+(N-1)*th;
h2=h1+th;
ah1=h2-h1;
bh1=(h2^2-h1^2)/2;
ch1=(h2^3-h1^3)/3;
% ———–
if(N <= nlayer/2 || N == 1)
theta=(1+(-1)^N)*pi/4;
else
theta = -1*(-1+(-1)^N)*pi/4;
end
% ————–
theta = rad2deg( theta );
t1=(cosd(theta))^4;
t2=(sind(theta))^4;
t3=(sind(theta)*cosd(theta))^2;
t4=sind(theta)*(cosd(theta))^3;
t5=cosd(theta)*(sind(theta))^3;
%**********************************************************
c111=c11*t1 + 2*(c12+2*c66)*t3 + c22*t2;
c121=(c11 + c22 – 4*c66)*t3 + c12*(t1+t2);
c221=c11*t2 + 2*(c12+2*c66)*t3 + c22*t1;
c161=(c11-c12-2*c66)*t4 + (c12-c22+2*c66)*t5;
c261=(c11-c12-2*c66)*t5 + (c12-c22+2*c66)*t4;
c661=(c11+c22-2*c12-2*c66)*t3 + c66*(t1+t2);
c441=c44*(cos(theta))^2 + c55*(sin(theta))^2;
c451=(c55-c44)*cos(theta)*sin(theta);
c551=c55*(cos(theta))^2 + c44*(sin(theta))^2;
Cb=[c111 c121 c161; c121 c221 c261; c161 c261 c661];
Cs=[c551 c451;c451 c441];
Dtrb = Dtrb + bh1*Cb;
end
but the resulting Dtrb atrix is not coming 0,
as you can see from fig: matrix for iteration 10 is bh1*Cb matrix which is added to Dtrb matrix and in figure both are same but opp in sign so if we add it should come 0 but as you can see in fig the result is not 0 but it is something * e-11 coming i am adding a matrix in for loop
Dtb=zeros(3,3);
Dtrb=Dtb;
Drrb=Dtb;
Dts=zeros(2,2);
for N=1:nlayer
h1=-h/2+(N-1)*th;
h2=h1+th;
ah1=h2-h1;
bh1=(h2^2-h1^2)/2;
ch1=(h2^3-h1^3)/3;
% ———–
if(N <= nlayer/2 || N == 1)
theta=(1+(-1)^N)*pi/4;
else
theta = -1*(-1+(-1)^N)*pi/4;
end
% ————–
theta = rad2deg( theta );
t1=(cosd(theta))^4;
t2=(sind(theta))^4;
t3=(sind(theta)*cosd(theta))^2;
t4=sind(theta)*(cosd(theta))^3;
t5=cosd(theta)*(sind(theta))^3;
%**********************************************************
c111=c11*t1 + 2*(c12+2*c66)*t3 + c22*t2;
c121=(c11 + c22 – 4*c66)*t3 + c12*(t1+t2);
c221=c11*t2 + 2*(c12+2*c66)*t3 + c22*t1;
c161=(c11-c12-2*c66)*t4 + (c12-c22+2*c66)*t5;
c261=(c11-c12-2*c66)*t5 + (c12-c22+2*c66)*t4;
c661=(c11+c22-2*c12-2*c66)*t3 + c66*(t1+t2);
c441=c44*(cos(theta))^2 + c55*(sin(theta))^2;
c451=(c55-c44)*cos(theta)*sin(theta);
c551=c55*(cos(theta))^2 + c44*(sin(theta))^2;
Cb=[c111 c121 c161; c121 c221 c261; c161 c261 c661];
Cs=[c551 c451;c451 c441];
Dtrb = Dtrb + bh1*Cb;
end
but the resulting Dtrb atrix is not coming 0,
as you can see from fig: matrix for iteration 10 is bh1*Cb matrix which is added to Dtrb matrix and in figure both are same but opp in sign so if we add it should come 0 but as you can see in fig the result is not 0 but it is something * e-11 coming matrix addition bug MATLAB Answers — New Questions