Tag Archives: matlab
Fitting multiple datasets with unique parameters using lsqcurvefit to a normalized function and constraints between datasets.
Thank you for taking the time to help. I will do my best to be clear and concise.
I have 3 sets of data (atttached), each with x and y data – not necesarilly the same length.
Each y(x) function can be normalized into p(t) using 4 parameters:
A – a constant that is extracted from each individual y(x), ‘A’ looks like [A1, A2, A3]
B – a fitting parameter unique to each y(x)
C – a fitting parameter applied to all y(x)
D – a constraint variable dependent on A and B applied to all y(x)
So the set looks something like:
I would like to use lsqcurvefit to fit my data to my function p(t) and output the unique (C and D) values.
I have a final constraint to increase the accuracy of lsqcurvefit: , where D is another global constant like C.
Where I’m at now, I want to adjust C and D to fit my function p(t) to y(x), but I don’t know how to also include the unique A values for each y(x).
I’ve pasted my current code below where I am able to get an individual fit for each y(x) but without consistent C and D parameters.
%% Data analysis
Results = NaN(3,2); % Result [C,D] for each individual fitting
for t = 1:3
%TL is summary matrix of all y(x) for the 3 experiments, NaN fills in
%where some y(x) are shorter than others.
x = TL(~isnan(TL(:,2*t-1)),2*t-1); %extracts x values from TL
y = TL(~isnan(TL(:,2*t)),2*t); %extracts y values from TL
%P = parameters: P(1) = C | P(2) = D
%fun below is the normalization for p(t)
fun = @(P,x)A(t)*(1-1/(2*(1-P(1))))*(1.304*exp(-(P(2)*x/(r/1000)^2).^0.5)-0.304*exp(-0.254*P(2)*x/(r/1000)^2))+1/(2*(1-P(1)));
P0 = [0.4, 1*10^-9]; %Initial parameters
lb = [0.1, 1*10^-10]; %Lower bound
ub = [0.5, 1*10^-8]; %Upper bound
Results(t,:) = lsqcurvefit(fun,P0,x,y,lb,ub); %Result consolidation for individual fitting
subplot(3,1,t)
plot(x,y,’ko’,x,fun(Results(t,:),x),’b-‘)
end
From looking at other posts on using lsqcurvefit with multiple datasets, I think my obstacle has come down to whether I should (1) run lsqcurvefit on all y(x) and somehow input the unique A constants or (2) run lsqcurvefit on individual y(x) and somehow correlate C and D to match between each fitting.
I hope this is presented clearly, looking forward to your thoughts and discussion – Thanks.Thank you for taking the time to help. I will do my best to be clear and concise.
I have 3 sets of data (atttached), each with x and y data – not necesarilly the same length.
Each y(x) function can be normalized into p(t) using 4 parameters:
A – a constant that is extracted from each individual y(x), ‘A’ looks like [A1, A2, A3]
B – a fitting parameter unique to each y(x)
C – a fitting parameter applied to all y(x)
D – a constraint variable dependent on A and B applied to all y(x)
So the set looks something like:
I would like to use lsqcurvefit to fit my data to my function p(t) and output the unique (C and D) values.
I have a final constraint to increase the accuracy of lsqcurvefit: , where D is another global constant like C.
Where I’m at now, I want to adjust C and D to fit my function p(t) to y(x), but I don’t know how to also include the unique A values for each y(x).
I’ve pasted my current code below where I am able to get an individual fit for each y(x) but without consistent C and D parameters.
%% Data analysis
Results = NaN(3,2); % Result [C,D] for each individual fitting
for t = 1:3
%TL is summary matrix of all y(x) for the 3 experiments, NaN fills in
%where some y(x) are shorter than others.
x = TL(~isnan(TL(:,2*t-1)),2*t-1); %extracts x values from TL
y = TL(~isnan(TL(:,2*t)),2*t); %extracts y values from TL
%P = parameters: P(1) = C | P(2) = D
%fun below is the normalization for p(t)
fun = @(P,x)A(t)*(1-1/(2*(1-P(1))))*(1.304*exp(-(P(2)*x/(r/1000)^2).^0.5)-0.304*exp(-0.254*P(2)*x/(r/1000)^2))+1/(2*(1-P(1)));
P0 = [0.4, 1*10^-9]; %Initial parameters
lb = [0.1, 1*10^-10]; %Lower bound
ub = [0.5, 1*10^-8]; %Upper bound
Results(t,:) = lsqcurvefit(fun,P0,x,y,lb,ub); %Result consolidation for individual fitting
subplot(3,1,t)
plot(x,y,’ko’,x,fun(Results(t,:),x),’b-‘)
end
From looking at other posts on using lsqcurvefit with multiple datasets, I think my obstacle has come down to whether I should (1) run lsqcurvefit on all y(x) and somehow input the unique A constants or (2) run lsqcurvefit on individual y(x) and somehow correlate C and D to match between each fitting.
I hope this is presented clearly, looking forward to your thoughts and discussion – Thanks. Thank you for taking the time to help. I will do my best to be clear and concise.
I have 3 sets of data (atttached), each with x and y data – not necesarilly the same length.
Each y(x) function can be normalized into p(t) using 4 parameters:
A – a constant that is extracted from each individual y(x), ‘A’ looks like [A1, A2, A3]
B – a fitting parameter unique to each y(x)
C – a fitting parameter applied to all y(x)
D – a constraint variable dependent on A and B applied to all y(x)
So the set looks something like:
I would like to use lsqcurvefit to fit my data to my function p(t) and output the unique (C and D) values.
I have a final constraint to increase the accuracy of lsqcurvefit: , where D is another global constant like C.
Where I’m at now, I want to adjust C and D to fit my function p(t) to y(x), but I don’t know how to also include the unique A values for each y(x).
I’ve pasted my current code below where I am able to get an individual fit for each y(x) but without consistent C and D parameters.
%% Data analysis
Results = NaN(3,2); % Result [C,D] for each individual fitting
for t = 1:3
%TL is summary matrix of all y(x) for the 3 experiments, NaN fills in
%where some y(x) are shorter than others.
x = TL(~isnan(TL(:,2*t-1)),2*t-1); %extracts x values from TL
y = TL(~isnan(TL(:,2*t)),2*t); %extracts y values from TL
%P = parameters: P(1) = C | P(2) = D
%fun below is the normalization for p(t)
fun = @(P,x)A(t)*(1-1/(2*(1-P(1))))*(1.304*exp(-(P(2)*x/(r/1000)^2).^0.5)-0.304*exp(-0.254*P(2)*x/(r/1000)^2))+1/(2*(1-P(1)));
P0 = [0.4, 1*10^-9]; %Initial parameters
lb = [0.1, 1*10^-10]; %Lower bound
ub = [0.5, 1*10^-8]; %Upper bound
Results(t,:) = lsqcurvefit(fun,P0,x,y,lb,ub); %Result consolidation for individual fitting
subplot(3,1,t)
plot(x,y,’ko’,x,fun(Results(t,:),x),’b-‘)
end
From looking at other posts on using lsqcurvefit with multiple datasets, I think my obstacle has come down to whether I should (1) run lsqcurvefit on all y(x) and somehow input the unique A constants or (2) run lsqcurvefit on individual y(x) and somehow correlate C and D to match between each fitting.
I hope this is presented clearly, looking forward to your thoughts and discussion – Thanks. lsqcurvefit, curve fitting, optimization MATLAB Answers — New Questions
In Matlab app When I delete a Editfieldnumeric component and delete it the call back function remains and when I next create a new component I do not see the callback
In one Matlab App I created a EditFieldNUmeric component and later deleted it. But the call back function remains.Why?
Also later I inserted a EditField numeric component ,I did not get the new callback function.Why?
Also please let me know how to use the numeric value in the call back function of another componentIn one Matlab App I created a EditFieldNUmeric component and later deleted it. But the call back function remains.Why?
Also later I inserted a EditField numeric component ,I did not get the new callback function.Why?
Also please let me know how to use the numeric value in the call back function of another component In one Matlab App I created a EditFieldNUmeric component and later deleted it. But the call back function remains.Why?
Also later I inserted a EditField numeric component ,I did not get the new callback function.Why?
Also please let me know how to use the numeric value in the call back function of another component editfieldnumeric in matlab app MATLAB Answers — New Questions
Transfer Functions on Biologic Data Sets
I have blast data from 3 different organisms. Two animals and one human set. I am looking to develop a transfer function to translate the data sets from animal set to the human data set. I also have the ambient pressure from outside of the body for normalization as well as weight, speed of the wave, and weight of the individual body parts. I only have acess to the following toolboxes:
MATLAB Version 9.8 (R2020a)
Curve Fitting Toolbox Version 3.5.11 (R2020a)
Deep Learning Toolbox Version 14.0 (R2020a)
GUI Layout Toolbox Version 2.3.6 (R2023a)
Signal Processing Toolbox Version 8.4 (R2020a)
Statistics and Machine Learning Toolbox Version 11.7 (R2020a)
I want to be able to set up some sort of optimizaiton funciton that would work between both of the animal models, independetly. Likely a second order model. I have attached the raw data of the pressures as a CSV. Each of the data sets are computed at 0.8Mhz and the data listed by row is an maximum individual test, not a continous data set.
I am looking for gudiance on how to start this.
>>I have blast data from 3 different organisms. Two animals and one human set. I am looking to develop a transfer function to translate the data sets from animal set to the human data set. I also have the ambient pressure from outside of the body for normalization as well as weight, speed of the wave, and weight of the individual body parts. I only have acess to the following toolboxes:
MATLAB Version 9.8 (R2020a)
Curve Fitting Toolbox Version 3.5.11 (R2020a)
Deep Learning Toolbox Version 14.0 (R2020a)
GUI Layout Toolbox Version 2.3.6 (R2023a)
Signal Processing Toolbox Version 8.4 (R2020a)
Statistics and Machine Learning Toolbox Version 11.7 (R2020a)
I want to be able to set up some sort of optimizaiton funciton that would work between both of the animal models, independetly. Likely a second order model. I have attached the raw data of the pressures as a CSV. Each of the data sets are computed at 0.8Mhz and the data listed by row is an maximum individual test, not a continous data set.
I am looking for gudiance on how to start this.
>> I have blast data from 3 different organisms. Two animals and one human set. I am looking to develop a transfer function to translate the data sets from animal set to the human data set. I also have the ambient pressure from outside of the body for normalization as well as weight, speed of the wave, and weight of the individual body parts. I only have acess to the following toolboxes:
MATLAB Version 9.8 (R2020a)
Curve Fitting Toolbox Version 3.5.11 (R2020a)
Deep Learning Toolbox Version 14.0 (R2020a)
GUI Layout Toolbox Version 2.3.6 (R2023a)
Signal Processing Toolbox Version 8.4 (R2020a)
Statistics and Machine Learning Toolbox Version 11.7 (R2020a)
I want to be able to set up some sort of optimizaiton funciton that would work between both of the animal models, independetly. Likely a second order model. I have attached the raw data of the pressures as a CSV. Each of the data sets are computed at 0.8Mhz and the data listed by row is an maximum individual test, not a continous data set.
I am looking for gudiance on how to start this.
>> transfer function, biologics, curve fitting MATLAB Answers — New Questions
Error in Model Fitting
Hello! i have been to run this model fitting code but keeps on getting these error messages as:
FUN must have two input arguments.
userFcn_ME = initEvalErrorHandler(userFcn_ME,funfcn_x_xdata{3}, …
[params_fit, ~] = lsqcurvefit(obj_fun, params0, time, observed_I, [], [], options);
Find attached, the code,, Please help
function dydt = sir_model(t, y, beta, gamma)
S = y(1);
I = y(2);
R = y(3);
N = S + I + R; % Total population
dSdt = -beta * S * I / N;
dIdt = beta * S * I / N – gamma * I;
dRdt = gamma * I;
dydt = [dSdt; dIdt; dRdt];
end
function error = model_error(params, time, observed_I, y0)
beta = params(1);
gamma = params(2);
% Solve the differential equations
[~, y] = ode45(@(t, y) sir_model(t, y, beta, gamma), time, y0);
% Extract the infectious data from the solution
model_I = y(:, 2);
% Compute the error as the difference between model and observed data
error = model_I – observed_I’;
end
% Define the time vector and observed data
time = [0, 1, 2, 3, 4, 5]; % Example time points
observed_I = [10, 15, 20, 25, 30, 35]; % Example observed infectious data
% Initial guess for parameters
beta_guess = 0.3;
gamma_guess = 0.1;
params0 = [beta_guess, gamma_guess];
% Initial conditions
S0 = 1000; % Initial number of susceptible individuals
I0 = observed_I(1); % Initial number of infectious individuals
R0 = 0; % Initial number of recovered individuals
y0 = [S0; I0; R0];
% Define the objective function for fitting
obj_fun = @(params) model_error(params, time, observed_I, y0);
% Perform the curve fitting
options = optimoptions(‘lsqcurvefit’, ‘Display’, ‘off’);
[params_fit, ~] = lsqcurvefit(obj_fun, params0, time, observed_I, [], [], options);
% Display the fitted parameters
beta_fit = params_fit(1);
gamma_fit = params_fit(2);
disp([‘Fitted beta: ‘, num2str(beta_fit)]);
disp([‘Fitted gamma: ‘, num2str(gamma_fit)]);Hello! i have been to run this model fitting code but keeps on getting these error messages as:
FUN must have two input arguments.
userFcn_ME = initEvalErrorHandler(userFcn_ME,funfcn_x_xdata{3}, …
[params_fit, ~] = lsqcurvefit(obj_fun, params0, time, observed_I, [], [], options);
Find attached, the code,, Please help
function dydt = sir_model(t, y, beta, gamma)
S = y(1);
I = y(2);
R = y(3);
N = S + I + R; % Total population
dSdt = -beta * S * I / N;
dIdt = beta * S * I / N – gamma * I;
dRdt = gamma * I;
dydt = [dSdt; dIdt; dRdt];
end
function error = model_error(params, time, observed_I, y0)
beta = params(1);
gamma = params(2);
% Solve the differential equations
[~, y] = ode45(@(t, y) sir_model(t, y, beta, gamma), time, y0);
% Extract the infectious data from the solution
model_I = y(:, 2);
% Compute the error as the difference between model and observed data
error = model_I – observed_I’;
end
% Define the time vector and observed data
time = [0, 1, 2, 3, 4, 5]; % Example time points
observed_I = [10, 15, 20, 25, 30, 35]; % Example observed infectious data
% Initial guess for parameters
beta_guess = 0.3;
gamma_guess = 0.1;
params0 = [beta_guess, gamma_guess];
% Initial conditions
S0 = 1000; % Initial number of susceptible individuals
I0 = observed_I(1); % Initial number of infectious individuals
R0 = 0; % Initial number of recovered individuals
y0 = [S0; I0; R0];
% Define the objective function for fitting
obj_fun = @(params) model_error(params, time, observed_I, y0);
% Perform the curve fitting
options = optimoptions(‘lsqcurvefit’, ‘Display’, ‘off’);
[params_fit, ~] = lsqcurvefit(obj_fun, params0, time, observed_I, [], [], options);
% Display the fitted parameters
beta_fit = params_fit(1);
gamma_fit = params_fit(2);
disp([‘Fitted beta: ‘, num2str(beta_fit)]);
disp([‘Fitted gamma: ‘, num2str(gamma_fit)]); Hello! i have been to run this model fitting code but keeps on getting these error messages as:
FUN must have two input arguments.
userFcn_ME = initEvalErrorHandler(userFcn_ME,funfcn_x_xdata{3}, …
[params_fit, ~] = lsqcurvefit(obj_fun, params0, time, observed_I, [], [], options);
Find attached, the code,, Please help
function dydt = sir_model(t, y, beta, gamma)
S = y(1);
I = y(2);
R = y(3);
N = S + I + R; % Total population
dSdt = -beta * S * I / N;
dIdt = beta * S * I / N – gamma * I;
dRdt = gamma * I;
dydt = [dSdt; dIdt; dRdt];
end
function error = model_error(params, time, observed_I, y0)
beta = params(1);
gamma = params(2);
% Solve the differential equations
[~, y] = ode45(@(t, y) sir_model(t, y, beta, gamma), time, y0);
% Extract the infectious data from the solution
model_I = y(:, 2);
% Compute the error as the difference between model and observed data
error = model_I – observed_I’;
end
% Define the time vector and observed data
time = [0, 1, 2, 3, 4, 5]; % Example time points
observed_I = [10, 15, 20, 25, 30, 35]; % Example observed infectious data
% Initial guess for parameters
beta_guess = 0.3;
gamma_guess = 0.1;
params0 = [beta_guess, gamma_guess];
% Initial conditions
S0 = 1000; % Initial number of susceptible individuals
I0 = observed_I(1); % Initial number of infectious individuals
R0 = 0; % Initial number of recovered individuals
y0 = [S0; I0; R0];
% Define the objective function for fitting
obj_fun = @(params) model_error(params, time, observed_I, y0);
% Perform the curve fitting
options = optimoptions(‘lsqcurvefit’, ‘Display’, ‘off’);
[params_fit, ~] = lsqcurvefit(obj_fun, params0, time, observed_I, [], [], options);
% Display the fitted parameters
beta_fit = params_fit(1);
gamma_fit = params_fit(2);
disp([‘Fitted beta: ‘, num2str(beta_fit)]);
disp([‘Fitted gamma: ‘, num2str(gamma_fit)]); model fitting MATLAB Answers — New Questions
How is the function FEEDBACK implemented in Matlab?
Hello together,
I used the function »feedback« to generate a closed-loop system, which worked well. Now I am trying to understand, how this function is mathematically implemented in Matlab. There are a lot of information’s, how to use the function, but I didn’t find anything which describes how it’s working and implemented mathematically. Does this function use iterative every sample from the output and add it to the input?
Thank you!Hello together,
I used the function »feedback« to generate a closed-loop system, which worked well. Now I am trying to understand, how this function is mathematically implemented in Matlab. There are a lot of information’s, how to use the function, but I didn’t find anything which describes how it’s working and implemented mathematically. Does this function use iterative every sample from the output and add it to the input?
Thank you! Hello together,
I used the function »feedback« to generate a closed-loop system, which worked well. Now I am trying to understand, how this function is mathematically implemented in Matlab. There are a lot of information’s, how to use the function, but I didn’t find anything which describes how it’s working and implemented mathematically. Does this function use iterative every sample from the output and add it to the input?
Thank you! feedback, closed loop, control MATLAB Answers — New Questions
Simulink Coder: Unknown type name mxarray
Hello. I have created a custom S Function block that outputs the sum of a user definable number of inputs and it works in simulation. The next step for me is to generate C code from it using Simulink Coder. For now I don’t want to inline the S function, I just want to test its autocoded functionality.
When I generate the src and header files and try to build an executable in eclipse I get the following errors:
unknown type name ‘RTWSfcnInfo’ in mymodel.h
unknown type name ‘mxarray’ in mymodel.h,simstruct_def.h, simstruct_internal.h
unknown type name ‘_ResolveVarFcn’ ini simstruct_def.h
#error unrecognized use in simstruct_compond.h
#error unhandled case in simstruct_compond.h
#error Must define one of RT, NRT, MATLAB_MEX_FILE, SL_INTERNAL, or FIPXT_SHARED_MODULE in simstruc_compcond.h
I have looked for a solution online and for other people this was solved by including mex.h – I have tried it and it did not work.
Thanks in advance!Hello. I have created a custom S Function block that outputs the sum of a user definable number of inputs and it works in simulation. The next step for me is to generate C code from it using Simulink Coder. For now I don’t want to inline the S function, I just want to test its autocoded functionality.
When I generate the src and header files and try to build an executable in eclipse I get the following errors:
unknown type name ‘RTWSfcnInfo’ in mymodel.h
unknown type name ‘mxarray’ in mymodel.h,simstruct_def.h, simstruct_internal.h
unknown type name ‘_ResolveVarFcn’ ini simstruct_def.h
#error unrecognized use in simstruct_compond.h
#error unhandled case in simstruct_compond.h
#error Must define one of RT, NRT, MATLAB_MEX_FILE, SL_INTERNAL, or FIPXT_SHARED_MODULE in simstruc_compcond.h
I have looked for a solution online and for other people this was solved by including mex.h – I have tried it and it did not work.
Thanks in advance! Hello. I have created a custom S Function block that outputs the sum of a user definable number of inputs and it works in simulation. The next step for me is to generate C code from it using Simulink Coder. For now I don’t want to inline the S function, I just want to test its autocoded functionality.
When I generate the src and header files and try to build an executable in eclipse I get the following errors:
unknown type name ‘RTWSfcnInfo’ in mymodel.h
unknown type name ‘mxarray’ in mymodel.h,simstruct_def.h, simstruct_internal.h
unknown type name ‘_ResolveVarFcn’ ini simstruct_def.h
#error unrecognized use in simstruct_compond.h
#error unhandled case in simstruct_compond.h
#error Must define one of RT, NRT, MATLAB_MEX_FILE, SL_INTERNAL, or FIPXT_SHARED_MODULE in simstruc_compcond.h
I have looked for a solution online and for other people this was solved by including mex.h – I have tried it and it did not work.
Thanks in advance! simulink, embedded coder, s-function MATLAB Answers — New Questions
Scaling dependence using equilibrate function
I want to use the function equilibrate, but I don’t understand the following written in Rescaling to Solve a Linear System.
"equilibrate is most useful when the scales of the b and x vectors in the original system x = Ab are irrelevant. However, if the scales of b and x are relevant, then using equilibrate to rescale A only for the linear system solve is not recommended. The obtained solution does not generally yield a small residual for the original system, even if expressed using the original basis vectors."
Could someone explain the meaning of this with an example?I want to use the function equilibrate, but I don’t understand the following written in Rescaling to Solve a Linear System.
"equilibrate is most useful when the scales of the b and x vectors in the original system x = Ab are irrelevant. However, if the scales of b and x are relevant, then using equilibrate to rescale A only for the linear system solve is not recommended. The obtained solution does not generally yield a small residual for the original system, even if expressed using the original basis vectors."
Could someone explain the meaning of this with an example? I want to use the function equilibrate, but I don’t understand the following written in Rescaling to Solve a Linear System.
"equilibrate is most useful when the scales of the b and x vectors in the original system x = Ab are irrelevant. However, if the scales of b and x are relevant, then using equilibrate to rescale A only for the linear system solve is not recommended. The obtained solution does not generally yield a small residual for the original system, even if expressed using the original basis vectors."
Could someone explain the meaning of this with an example? matrices MATLAB Answers — New Questions
toggle and elseif in matlab
Try adding a variable doDisplay to toggle if the densities are displayed. Add this condition with an elseif block.
i do not understand what we are supposed to do in the above question(bold). this question is a part of futher practice in mathlab oramp. decision branching topic futher practice section in matworks course for basic matlab. how do i solve tha bove question
https://matlabacademy.mathworks.com/R2019b/portal.html?course=gettingstarted#chapter=13&lesson=2§ion=1Try adding a variable doDisplay to toggle if the densities are displayed. Add this condition with an elseif block.
i do not understand what we are supposed to do in the above question(bold). this question is a part of futher practice in mathlab oramp. decision branching topic futher practice section in matworks course for basic matlab. how do i solve tha bove question
https://matlabacademy.mathworks.com/R2019b/portal.html?course=gettingstarted#chapter=13&lesson=2§ion=1 Try adding a variable doDisplay to toggle if the densities are displayed. Add this condition with an elseif block.
i do not understand what we are supposed to do in the above question(bold). this question is a part of futher practice in mathlab oramp. decision branching topic futher practice section in matworks course for basic matlab. how do i solve tha bove question
https://matlabacademy.mathworks.com/R2019b/portal.html?course=gettingstarted#chapter=13&lesson=2§ion=1 elseif, toggle, decision branching MATLAB Answers — New Questions
How to find the roots of a non-polynomial equation in terms of symbolic variables ?
want to find the values of ‘K’ for which the function (D) becomes zero. ‘L’ and ‘a’ are the constants. Code:
syms A B L K a
D = [cosh(K*L)-cos(K*L), sinh(K*L)-sin(K*L); sinh(K*L)+sin(K*L)+K*a*L*(cosh(K*L)+cos(K*L)), cosh(K*L)-cos(K*L)+K*a*L*(sinh(K*L)+sin(K*L))];
d = det(D)
fzero(@(K) d, 10)
Error using fzero (line 309) Function value at starting guess must be finite and real.want to find the values of ‘K’ for which the function (D) becomes zero. ‘L’ and ‘a’ are the constants. Code:
syms A B L K a
D = [cosh(K*L)-cos(K*L), sinh(K*L)-sin(K*L); sinh(K*L)+sin(K*L)+K*a*L*(cosh(K*L)+cos(K*L)), cosh(K*L)-cos(K*L)+K*a*L*(sinh(K*L)+sin(K*L))];
d = det(D)
fzero(@(K) d, 10)
Error using fzero (line 309) Function value at starting guess must be finite and real. want to find the values of ‘K’ for which the function (D) becomes zero. ‘L’ and ‘a’ are the constants. Code:
syms A B L K a
D = [cosh(K*L)-cos(K*L), sinh(K*L)-sin(K*L); sinh(K*L)+sin(K*L)+K*a*L*(cosh(K*L)+cos(K*L)), cosh(K*L)-cos(K*L)+K*a*L*(sinh(K*L)+sin(K*L))];
d = det(D)
fzero(@(K) d, 10)
Error using fzero (line 309) Function value at starting guess must be finite and real. roots, non-polynomial MATLAB Answers — New Questions
Can’t do any courses on Mac
Whenever I open MATLAB Onramp or Simulink Onramp or any other courses I can’t get past the first page. Sometimes I can play the introductory video but afterwards the pointer cursor dissapears and I can’t interact with anything on the page and have to quit the tab. This has occured on the two most recent versions on three different browsers, I have cleared my cache for MATLAB and I am on macOS Sonoma.Whenever I open MATLAB Onramp or Simulink Onramp or any other courses I can’t get past the first page. Sometimes I can play the introductory video but afterwards the pointer cursor dissapears and I can’t interact with anything on the page and have to quit the tab. This has occured on the two most recent versions on three different browsers, I have cleared my cache for MATLAB and I am on macOS Sonoma. Whenever I open MATLAB Onramp or Simulink Onramp or any other courses I can’t get past the first page. Sometimes I can play the introductory video but afterwards the pointer cursor dissapears and I can’t interact with anything on the page and have to quit the tab. This has occured on the two most recent versions on three different browsers, I have cleared my cache for MATLAB and I am on macOS Sonoma. matlab MATLAB Answers — New Questions
Is code generation supported for “convolution1DLayer”?
Is code generation supported for "convolution1DLayer"?Is code generation supported for "convolution1DLayer"? Is code generation supported for "convolution1DLayer"? code, generation, convolution1dlayer, convolution, 1d, layer, deep, learning, neural, network, matlab, coder, spatial, temporal MATLAB Answers — New Questions
gwagwagagwa wag wa aggwagw
gwawagaggwawagag gwawagag thingspeak MATLAB Answers — New Questions
Indexing/Accessing Entire Columns of Nested Array
I have a nested cell array {48×691}. I would like to isolate an entire column of the nested cell array while grabbing all of the rows such that I would get the nested arrays in this way:
{:,1} {:, 2} {:,3} … {:,691}
In other words, how do I get all of the 691 columns from the nested array extracted such that I grab the 48 rows each time?
Thank you!I have a nested cell array {48×691}. I would like to isolate an entire column of the nested cell array while grabbing all of the rows such that I would get the nested arrays in this way:
{:,1} {:, 2} {:,3} … {:,691}
In other words, how do I get all of the 691 columns from the nested array extracted such that I grab the 48 rows each time?
Thank you! I have a nested cell array {48×691}. I would like to isolate an entire column of the nested cell array while grabbing all of the rows such that I would get the nested arrays in this way:
{:,1} {:, 2} {:,3} … {:,691}
In other words, how do I get all of the 691 columns from the nested array extracted such that I grab the 48 rows each time?
Thank you! indexing nested cell array, nested cell array, indexing MATLAB Answers — New Questions
Work Around for Convolution1DLayer
I am trying to do code generation of a trained deep learning network however it uses a convolution1dlayer. It seems this is not currently supported by matlab. What are some possible solutions to this problem?I am trying to do code generation of a trained deep learning network however it uses a convolution1dlayer. It seems this is not currently supported by matlab. What are some possible solutions to this problem? I am trying to do code generation of a trained deep learning network however it uses a convolution1dlayer. It seems this is not currently supported by matlab. What are some possible solutions to this problem? deep learning, code generation MATLAB Answers — New Questions
Can I run protected Simulink models in External mode before R2023b?
I am trying to run a Simulink mode via External Mode. Part of my model is a Protected Model Reference and I am using a release before release MATLAB R2023b.
If I attempt to run this model in External Mode it fails with the following error message:
Protected models do not work in External mode or rapid accelerator simulations.
Is it possible to protect a model and still be able to run it in External mode on these releases?I am trying to run a Simulink mode via External Mode. Part of my model is a Protected Model Reference and I am using a release before release MATLAB R2023b.
If I attempt to run this model in External Mode it fails with the following error message:
Protected models do not work in External mode or rapid accelerator simulations.
Is it possible to protect a model and still be able to run it in External mode on these releases? I am trying to run a Simulink mode via External Mode. Part of my model is a Protected Model Reference and I am using a release before release MATLAB R2023b.
If I attempt to run this model in External Mode it fails with the following error message:
Protected models do not work in External mode or rapid accelerator simulations.
Is it possible to protect a model and still be able to run it in External mode on these releases? protected, external, mode MATLAB Answers — New Questions
Can i use protected models in external mode?
I want created a Simulink Library for my Arduino Hardware. I created a model reference block and then convert a protected this block using callback.
But I run on External Mode, get this error :
Protected models do not work in External mode or rapid accelerator simulations.
Is there any solution method for this problem ?I want created a Simulink Library for my Arduino Hardware. I created a model reference block and then convert a protected this block using callback.
But I run on External Mode, get this error :
Protected models do not work in External mode or rapid accelerator simulations.
Is there any solution method for this problem ? I want created a Simulink Library for my Arduino Hardware. I created a model reference block and then convert a protected this block using callback.
But I run on External Mode, get this error :
Protected models do not work in External mode or rapid accelerator simulations.
Is there any solution method for this problem ? protected block, block, referenced model MATLAB Answers — New Questions
Matlab asks me to sign in when I’m offline
Matlab asks me to sign in when I’m offline, as this is impossible I can’t use Matlab while offline.
I can use Matlab no problem when I’m online and it does not ask me to sign in.
When I’m offline a Sign In window appears with this error:
Unable to contact login services. There may be a problem with your internet connection, or the service may be temporarily unavailable. If the problem persists contact MathWorks technical support.
Any fix for this?Matlab asks me to sign in when I’m offline, as this is impossible I can’t use Matlab while offline.
I can use Matlab no problem when I’m online and it does not ask me to sign in.
When I’m offline a Sign In window appears with this error:
Unable to contact login services. There may be a problem with your internet connection, or the service may be temporarily unavailable. If the problem persists contact MathWorks technical support.
Any fix for this? Matlab asks me to sign in when I’m offline, as this is impossible I can’t use Matlab while offline.
I can use Matlab no problem when I’m online and it does not ask me to sign in.
When I’m offline a Sign In window appears with this error:
Unable to contact login services. There may be a problem with your internet connection, or the service may be temporarily unavailable. If the problem persists contact MathWorks technical support.
Any fix for this? login, offline MATLAB Answers — New Questions
Bar chart from Excel with hidden columns
Hi there
I want to create the attached chart (plus an average line per section) with Matlab. I can do it super quick with Excel, but unfortunately it didn´t work well with Matlab.
There are three complications for me. 1 – How can I can exclude the hidden columns? 2 – What is the best way to deal with German numbers with comma instead of point? 3 -And Is there any way to have an average line per section?
Seems the "readtable" doesn´t work well with commas.
ThanksHi there
I want to create the attached chart (plus an average line per section) with Matlab. I can do it super quick with Excel, but unfortunately it didn´t work well with Matlab.
There are three complications for me. 1 – How can I can exclude the hidden columns? 2 – What is the best way to deal with German numbers with comma instead of point? 3 -And Is there any way to have an average line per section?
Seems the "readtable" doesn´t work well with commas.
Thanks Hi there
I want to create the attached chart (plus an average line per section) with Matlab. I can do it super quick with Excel, but unfortunately it didn´t work well with Matlab.
There are three complications for me. 1 – How can I can exclude the hidden columns? 2 – What is the best way to deal with German numbers with comma instead of point? 3 -And Is there any way to have an average line per section?
Seems the "readtable" doesn´t work well with commas.
Thanks excel MATLAB Answers — New Questions
how to mirror plots?
i hv theta value as 60 and 61 each theta value has phi of 120 240 with corresponding total values.
i hv to mirror data that is phi values data from 120 to 180 should be mirrored to 180 to 240 and then its plot is plotted. aim is to get plots symmetry xaxis is phi y axis is total with respect to theta percentile plots.i hv tried with excel sheet but my data is in .tab file how to import that format file and plot from it
a=xlsread(‘1GHzHH.xlsx’);
theta=a(:,1);
phi=a(:,2);
total=a(:,3);
figure
plot(phi,total)
% f=[1];
% pol=[‘HH”VV’];
%
% for i=1:size(pol)
% m=strcat(pol,’GHz’)
% j=strcat(f,m) %i m trying to read file which i hv imported file name is 1GHzHH.tab
% theta=data(:,1);
% phi=data(:,2);
% total=data(:,3);
% for j=1:nume1(theta)
% for k=1:nume1(phi)
%
% end
% end
% endi hv theta value as 60 and 61 each theta value has phi of 120 240 with corresponding total values.
i hv to mirror data that is phi values data from 120 to 180 should be mirrored to 180 to 240 and then its plot is plotted. aim is to get plots symmetry xaxis is phi y axis is total with respect to theta percentile plots.i hv tried with excel sheet but my data is in .tab file how to import that format file and plot from it
a=xlsread(‘1GHzHH.xlsx’);
theta=a(:,1);
phi=a(:,2);
total=a(:,3);
figure
plot(phi,total)
% f=[1];
% pol=[‘HH”VV’];
%
% for i=1:size(pol)
% m=strcat(pol,’GHz’)
% j=strcat(f,m) %i m trying to read file which i hv imported file name is 1GHzHH.tab
% theta=data(:,1);
% phi=data(:,2);
% total=data(:,3);
% for j=1:nume1(theta)
% for k=1:nume1(phi)
%
% end
% end
% end i hv theta value as 60 and 61 each theta value has phi of 120 240 with corresponding total values.
i hv to mirror data that is phi values data from 120 to 180 should be mirrored to 180 to 240 and then its plot is plotted. aim is to get plots symmetry xaxis is phi y axis is total with respect to theta percentile plots.i hv tried with excel sheet but my data is in .tab file how to import that format file and plot from it
a=xlsread(‘1GHzHH.xlsx’);
theta=a(:,1);
phi=a(:,2);
total=a(:,3);
figure
plot(phi,total)
% f=[1];
% pol=[‘HH”VV’];
%
% for i=1:size(pol)
% m=strcat(pol,’GHz’)
% j=strcat(f,m) %i m trying to read file which i hv imported file name is 1GHzHH.tab
% theta=data(:,1);
% phi=data(:,2);
% total=data(:,3);
% for j=1:nume1(theta)
% for k=1:nume1(phi)
%
% end
% end
% end plot MATLAB Answers — New Questions
How to convert euler angles to rotation matrix and back to euler angles consistently?
I want to compare the rotations from two different sources. However, I can do it only in R3, using Euler angles. However, it seems even for an elementary conversion, we don’t get matching euler vectors. I know that there can be non-unique representations for the same rotation matrix, but is there a way, where I can enforce some particular angle range output so that the vectors match? Maybe a constraint like rotation in Z has to be positive.
For eg.
%% Euler Angle -> Rotation Matrix -> Euler Angle
Rzc = -0.0030; Ryc = -2.4788; Rxc = 0.0180;
eul_seq_c_in = [Rzc, Ryc, Rxc]
rotm_c = eul2rotm(eul_seq_c_in);
eul_seq_c_out = rotm2eul(rotm_c)
%% Many to One Mapping for Euler Angle
eul2rotm(eul_seq_c_in)
eul2rotm(eul_seq_c_out)
For my application, all I get is a sequence of euler angles as an input. Then, I get a rotation transform independently, whose Euler sequence is calculated. And then I verify, if they represent the same rotation transform.I want to compare the rotations from two different sources. However, I can do it only in R3, using Euler angles. However, it seems even for an elementary conversion, we don’t get matching euler vectors. I know that there can be non-unique representations for the same rotation matrix, but is there a way, where I can enforce some particular angle range output so that the vectors match? Maybe a constraint like rotation in Z has to be positive.
For eg.
%% Euler Angle -> Rotation Matrix -> Euler Angle
Rzc = -0.0030; Ryc = -2.4788; Rxc = 0.0180;
eul_seq_c_in = [Rzc, Ryc, Rxc]
rotm_c = eul2rotm(eul_seq_c_in);
eul_seq_c_out = rotm2eul(rotm_c)
%% Many to One Mapping for Euler Angle
eul2rotm(eul_seq_c_in)
eul2rotm(eul_seq_c_out)
For my application, all I get is a sequence of euler angles as an input. Then, I get a rotation transform independently, whose Euler sequence is calculated. And then I verify, if they represent the same rotation transform. I want to compare the rotations from two different sources. However, I can do it only in R3, using Euler angles. However, it seems even for an elementary conversion, we don’t get matching euler vectors. I know that there can be non-unique representations for the same rotation matrix, but is there a way, where I can enforce some particular angle range output so that the vectors match? Maybe a constraint like rotation in Z has to be positive.
For eg.
%% Euler Angle -> Rotation Matrix -> Euler Angle
Rzc = -0.0030; Ryc = -2.4788; Rxc = 0.0180;
eul_seq_c_in = [Rzc, Ryc, Rxc]
rotm_c = eul2rotm(eul_seq_c_in);
eul_seq_c_out = rotm2eul(rotm_c)
%% Many to One Mapping for Euler Angle
eul2rotm(eul_seq_c_in)
eul2rotm(eul_seq_c_out)
For my application, all I get is a sequence of euler angles as an input. Then, I get a rotation transform independently, whose Euler sequence is calculated. And then I verify, if they represent the same rotation transform. rotation, transforms, euler MATLAB Answers — New Questions