how to store and use previous values of a variable in simulink during simulation?

5 views (last 30 days)
So I would like to be able to store values and DURING the simulation being able to take 'N' samples that was calculated before and use them . (say like last 500 samples)
Yes I know that you can use delays for the example but what I would like to program is more complicated than the example so using delays is not an option.
Thanks ,
Vemuri
  1 Comment
Kaustubha Govind
Kaustubha Govind on 17 Feb 2014
I received a personal message from you regarding this question. Please be considerate and avoid sending personal messages to contributors on this forum. All users participate voluntarily, and in their spare time. It is forum etiquette to first search for a solution to your problem on the forum to see if it has been answered before. If you do not find a solution, formulate your problem well and post it as a question on the forum. Be patient and allow time for it to be answered.

Sign in to comment.

Answers (1)

Kaustubha Govind
Kaustubha Govind on 17 Feb 2014
As far as I know, using some of form of delays is the only way to store values from previous time-steps. Perhaps you could explain why delays are not adequate?
  1 Comment
Sri hari Krishna
Sri hari Krishna on 17 Feb 2014
this is the part of my code i am facing the problem with, When used in a normal code it works fine. when i try to embed the same thing in my simulink model.. it says "Simulation stopped due to out of bounds error. Enable debugging to pinpoint the location of the error". So How do I get it fixed , so as to access the previous values during simulation???
' if (mod(t,500)==0) %---detection
e1=sum(error(t-249:t).^2);%latest
e2=sum(error(t-499:t-250).^2);%previous
itr=itr+1;
end

Sign in to comment.

Categories

Find more on Simulink in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!