Group Abstract Group Abstract

Message Boards Message Boards

[?] Avoid differences between solutions by NDsolve and by OutputResponse?

2 Replies

Neil,

Thanks for you suggestion. You are right, it has to do with the delay. There are two way to delay a state variable 1) x[t-tau] or 2) SystemModelDelay[tau] x[t]. They are equivalent according to the documentation but in this case they are not. I found that the following code it does work

f = 60;
h = 3;(*Harmonic number*)

u1[t_] = Sin[2 \[Pi] f t] + 5 Cos[2 \[Pi] 3 f t] + 
  0.8 Cos[2 \[Pi] 6 f t] + 3;
tau = 1/f;
m1 = StateSpaceModel[{ff1'[t] == signal[t] Cos[2 \[Pi] h f t], 
   f2'[t] ==   SystemsModelDelay[tau] ff1'[t]}, {ff1[t], 
   f2[t]}, {signal[t]}, {2 f (ff1[t] - f2[t])}, t]
y1 = OutputResponse[m1, u1[t], {t, 0, 3 tau}];
Plot[y1, {t, 0, 3 tau}]

enter image description here

Interestingly, the resulting state space model is in Descriptor Form

enter image description here

I am going on to my control books to properly understand why!

Cheers Jesús

Jesus,

I believe that your problem stems from the fact that the StateSpaceModel assumes the functions exist before time 0 and the NDSolve solution explicitly sets the functions to zero. You can see this by plotting the function f2 (which is a delayed version of ff1):

enter image description here

You need to add a time delay to the StateSpaceModel with SystemsModelDelay or by including the delay in the equations:

m1=StateSpaceModel[{ff1'[t]==signal[t] Cos[2 \[Pi] h f t],f2'[t]==ff1'[t-tau]},{ff1[t],f2[t]},{signal[t]},{2 f (ff1[t-tau])},t]
y1=OutputResponse[m1,u1[t],{t,0,3 tau}];
Plot[y1,{t,0,3 tau}]

Which gives the delayed plot for f2 (which matches the image above).

I am not quite sure why having the tau explicitly in the output of StateSpaceModel automatically adds the SystemsModelDelay while the way you entered it does not. If you look into the documentation maybe you can figure it out and post the reason.

Regards

POSTED BY: Neil Singer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard