Too many input arguments - idgrey
10 views (last 30 days)
Show older comments
Gennaro Sorrentino
on 27 Sep 2024
Commented: Gennaro Sorrentino
on 27 Sep 2024
Hello everyone,
I'm trying to define a grey box model for parameters identification
pars = {ms; mu; meq; ceq; ks; ku; cu; km; cm};
linear_model = idgrey('QC_rot_func',pars,'c');
but I'm getting this error when running the model:
Error using idgrey (line 367)
The ODE function "QC_rot_func" could not be evaluated successfully using the given set of parameters, sample time
and optional arguments. The error message generated during the evaluation was:
Too many input arguments.
Error in main (line 175)
linear_model = idgrey('QC_rot_func',pars,'c');
The function 'QC_rot_func' is the following:
function [A,B,C,D] = QC_rot_func(pars,Ts)
ms = pars(1);
mu = pars(2);
meq = pars(3);
ceq = pars(4);
ks = pars(5);
ku = pars(6);
cu = pars(7);
km = pars(8);
cm = pars(9);
A = [0 0 0 1 -1 0;
0 0 0 0 1 -1;
0 0 0 0 0 1;
(-ks/ms-km/ms) -ks/ms 0 -cm/ms cm/ms 0;
(ks/mu+km/mu+km/meq) ks/mu -ku/mu (cm/mu+cm/meq) (-cm/mu-cm/meq-ceq/meq) (-cu/mu+ceq/meq);
(ks/mu+km/mu) ks/mu -ku/mu cm/mu -cm/mu -cu/mu];
Bd = [0; 0; -1; 0; cu/mu; cu/mu];
Bdlt = [0; 0; 0; 1/ms; 0; 0];
Bu = [0; 0; 0; 0; 1/meq; 0];
B = [Bd Bdlt Bu];
C = [A(4,:); A(6,:); A(1,:)+A(2,:)];
D = [B(4,:); B(6,:); B(1,:)+B(2,:)];
end
What is the problem in this code? If I try to run the function with parameters as input, I get di A B C D matrices as expected.
Thank you.
0 Comments
Accepted Answer
Cris LaPierre
on 27 Sep 2024
The error is in how you define your odefun. Although you pass in all the parameters in a single cell array, your function declaration must still list each variable separately. See this doc example.
Here's an example that runs here.
ms = 5;
mu = 4;
meq = 3;
ceq = 2;
ks = 3;
ku = 4;
cu = 5;
km = 6;
cm = 5;
pars = {ms; mu; meq; ceq; ks; ku; cu; km; cm};
linear_model = idgrey(@QC_rot_func,pars,'c')
function [A,B,C,D] = QC_rot_func(ms, mu, meq, ceq, ks, ku, cu, km, cm, Ts)
A = [0 0 0 1 -1 0;
0 0 0 0 1 -1;
0 0 0 0 0 1;
(-ks/ms-km/ms) -ks/ms 0 -cm/ms cm/ms 0;
(ks/mu+km/mu+km/meq) ks/mu -ku/mu (cm/mu+cm/meq) (-cm/mu-cm/meq-ceq/meq) (-cu/mu+ceq/meq);
(ks/mu+km/mu) ks/mu -ku/mu cm/mu -cm/mu -cu/mu];
Bd = [0; 0; -1; 0; cu/mu; cu/mu];
Bdlt = [0; 0; 0; 1/ms; 0; 0];
Bu = [0; 0; 0; 0; 1/meq; 0];
B = [Bd Bdlt Bu];
C = [A(4,:); A(6,:); A(1,:)+A(2,:)];
D = [B(4,:); B(6,:); B(1,:)+B(2,:)];
end
More Answers (0)
See Also
Categories
Find more on Model Predictive Control Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!