Too many input arguments - idgrey

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.

 Risposta accettata

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')
linear_model = Continuous-time linear grey box model defined by @QC_rot_func function: dx/dt = A x(t) + B u(t) + K e(t) y(t) = C x(t) + D u(t) + e(t) A = x1 x2 x3 x4 x5 x6 x1 0 0 0 1 -1 0 x2 0 0 0 0 1 -1 x3 0 0 0 0 0 1 x4 -1.8 -0.6 0 -1 1 0 x5 4.25 0.75 -1 2.917 -3.583 -0.5833 x6 2.25 0.75 -1 1.25 -1.25 -1.25 B = u1 u2 u3 x1 0 0 0 x2 0 0 0 x3 -1 0 0 x4 0 0.2 0 x5 1.25 0 0.3333 x6 1.25 0 0 C = x1 x2 x3 x4 x5 x6 y1 -1.8 -0.6 0 -1 1 0 y2 2.25 0.75 -1 1.25 -1.25 -1.25 y3 0 0 0 1 0 -1 D = u1 u2 u3 y1 0 0.2 0 y2 1.25 0 0 y3 0 0 0 K = y1 y2 y3 x1 0 0 0 x2 0 0 0 x3 0 0 0 x4 0 0 0 x5 0 0 0 x6 0 0 0 Model parameters: Par1 = 5 Par2 = 4 Par3 = 3 Par4 = 2 Par5 = 3 Par6 = 4 Par7 = 5 Par8 = 6 Par9 = 5 Parameterization: ODE Function: @QC_rot_func Disturbance component: none Initial state: 'auto' Number of free coefficients: 9 Use "getpvec", "getcov" for parameters and their uncertainties. Status: Created by direct construction or transformation. Not estimated.
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

1 Commento

Problem solved defining the function as yours, thank you very much!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su System Identification Toolbox in Centro assistenza e File Exchange

Prodotti

Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by