Effacer les filtres
Effacer les filtres

Discrete systems using s-function

2 vues (au cours des 30 derniers jours)
dab483
dab483 le 22 Jan 2012
Hi,
i have this discrete function, and try to simulate it using s-function level 2, where k represent simulation length from 1 to 50sec.
x(k) = 0.5*x(k-1) + 25*x(k-1) /(1 + x(k-1)^2) + 8 cos(1.2(k-1))
here how i put it in the s-function level 2:
function Update(block)
Q=1;
xplus = 0.5 * xminus + 25 * xminus / (1 + xminus^2) + 8 * cos(1.2*(k-1))
block.Dwork(1).Data = xplus;
where xplus = x(k) xminus=x(k-1)
but i am not sure about cos(1.2*(k-1)). Can anyone pls advise how should i implement this? Thanks.

Réponse acceptée

Kaustubha Govind
Kaustubha Govind le 23 Jan 2012
Is (k-1) basically "t" at the previous step, where t is the current simulation time-step? If yes, you can store "t" in a Dwork by using block.CurrentTime and use it in the next time step as (k-1).
  3 commentaires
Kaustubha Govind
Kaustubha Govind le 23 Jan 2012
Same way you are storing 'xplus' in your example:
% Register two DWorks in DoPostPropSetup
block.NumDworks = 2;
% In Update
block.Dwork(2).Data = block.CurrentTime;
dab483
dab483 le 23 Jan 2012
Thank you very much..

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur View and Analyze Simulation Results dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by