Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to use simulink get the value from last cycle(step)?

Subject: how to use simulink get the value from last cycle(step)?

From: cdrsir

Date: 23 May, 2006 03:05:48

Message: 1 of 6

the general idea in C/C++ is as followings:

while(true)
{
    // actual position
    p_actual = value_from_sensor();

    // actual velocity
    v_actual = (p_actual - p_last) / time_step;

    // store the actual position for the next step
    p_last = p_actual; --> how to do this step in simulink?
}

in order to calculate the v_actual, I have to store the position from
last step, but how to store this value in simulink?

Subject: how to use simulink get the value from last cycle(step)?

From: cdrsir

Date: 23 May, 2006 03:13:52

Message: 2 of 6

Is it possible to do so without using any "Data Store Memory" blocks? I
do not like them.

cdrsir =E5=86=99=E9=81=93=EF=BC=9A

> the general idea in C/C++ is as followings:
>
> while(true)
> {
> // actual position
> p_actual =3D value_from_sensor();
>
> // actual velocity
> v_actual =3D (p_actual - p_last) / time_step;
>
> // store the actual position for the next step
> p_last =3D p_actual; --> how to do this step in simulink?
> }
>
> in order to calculate the v_actual, I have to store the position from
> last step, but how to store this value in simulink?

Subject: how to use simulink get the value from last cycle(step)?

From: teoman

Date: 19 Nov, 2012 12:59:07

Message: 3 of 6

i need this question's answer. i have a distance calculator and it changes on time. i need to get last value and time for calculate velocity.

Subject: how to use simulink get the value from last cycle(step)?

From: Phil Goddard

Date: 19 Nov, 2012 15:58:14

Message: 4 of 6

In a discrete system you use a Unit Delay block.
In a continuous system you use a Memory block.

Phil.

Subject: how to use simulink get the value from last cycle(step)?

From: teoman

Date: 23 Nov, 2012 12:15:08

Message: 5 of 6

thanks Phil but it's not working again. i have latitude and longitude signals when i switch i want to save first coordinate and i want to calculate the distance with second coordinate. And i think i can pass the velocity calculation

Subject: how to use simulink get the value from last cycle(step)?

From: teoman

Date: 28 Nov, 2012 08:25:49

Message: 6 of 6

i find the answer actually. i added a trigger subsysytem and i used triggered to workspace. when i open the switch data is saving on time.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us