My model output is different with use of Simulink and sim function

2 vues (au cours des 30 derniers jours)
Saeed
Saeed le 23 Mai 2013
I have a NARX model with 4 input and 1 output. I use Iddata Source, Nonlinear ARX Model and Siganl to workspace bolck in Simulink. The simulation stop time is 100 and i use these code for iddata object and model initial state:
XX = iddata(out, in, 1);
[X1,U1,REPORT1] = findop(MN1,'steady',[in(1,1),in(1,2),in(1,3),in(1,4)],NaN);
After run, output from signal to workspace block contain 101 data!?. and I have to erase the first data because I don’t need it. This issue happened to me for several other problem in Simulink such as MPC or PID or other model that the block output is always have one extra data.
Next problem is that, when I use same model with same iddata and initial state with sim function, I get 100 output data, but completely different from Simulink output!?
mout11=sim(MN1,XX,'init',X1);
mout1=mout11.OutputData; %Extracting data to array matrix
Can anyone help me?

Réponse acceptée

Rajiv Singh
Rajiv Singh le 25 Mai 2013
For iddata source, it helps to set Tstart to 0 since the simulation in Simulink starts there by default. That is, use: XX = iddata(out, in, 1, 'Tstart', 0)
For matching simulation response, you have to set the initial conditions correctly. See:
  2 commentaires
Saeed
Saeed le 26 Mai 2013
Thank U for Ur help. the link was very helpful too. Just to be sure, when the focus option be on prediction and the created model be used in Simulink or SIM command, is the output count for simulation or prediction?
Rajiv Singh
Rajiv Singh le 26 Mai 2013
Once a model is available it can be used for either prediction or simulation. SIM command (or Simulink) will give you simulated response. PREDICT command will give you predicted response. See also: http://www.mathworks.com/matlabcentral/answers/5391-doubt-on-the-block-diagram-of-the-narx-model-matlab-documentation

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Model Predictive Control Toolbox dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by