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:
Timing in matlab simulation

Subject: Timing in matlab simulation

From: MICHAEL

Date: 29 Sep, 2010 17:01:21

Message: 1 of 4

hello

for my simulation, i need to do timing - a function to run on constant time delays, no matter what (for example during the simulation, the program should do measurements on constant time interval, meanwhile it do some calculation on the measurments)
how do i do it?

Subject: Timing in matlab simulation

From: Pieter Chys

Date: 3 Oct, 2010 10:22:06

Message: 2 of 4

Hello Michael,

You could use:

pause on
 for i = 1:n
       pause(n)
       your simulation function....

end

with n a nonnegative real number (when the time
interval is not too small because for high resolution
there can be high relative error). If exactness is
important at small time scales you should check out
info on 'time and date operations' at Mathworks
Matlab info pages. It is certainly possible.

Regards,
Pieter Chys.

"michael" <bezenchu@gmail.com> wrote in message <i7vrd1$njl$1@fred.mathworks.com>...
> hello
>
> for my simulation, i need to do timing - a function to run on constant time delays, no matter what (for example during the simulation, the program should do measurements on constant time interval, meanwhile it do some calculation on the measurments)
> how do i do it?

Subject: Timing in matlab simulation

From: MICHAEL

Date: 8 Oct, 2010 06:26:04

Message: 3 of 4

but when i do the pause, i can't do other calculations
for example - i wanna calculate speed of rotation of car wheel:
each second there is sampling.
after the taking some sample till next sample there should be time (less then second because the duration of the taking the sample) in which i want to do some calculations.
according your proposal - i can't

"Pieter Chys" <pieter@cib.csic.es> wrote in message <i89lge$orq$1@fred.mathworks.com>...
> Hello Michael,
>
> You could use:
>
> pause on
> for i = 1:n
> pause(n)
> your simulation function....
>
> end
>
> with n a nonnegative real number (when the time
> interval is not too small because for high resolution
> there can be high relative error). If exactness is
> important at small time scales you should check out
> info on 'time and date operations' at Mathworks
> Matlab info pages. It is certainly possible.
>
> Regards,
> Pieter Chys.
>
> "michael" <bezenchu@gmail.com> wrote in message <i7vrd1$njl$1@fred.mathworks.com>...
> > hello
> >
> > for my simulation, i need to do timing - a function to run on constant time delays, no matter what (for example during the simulation, the program should do measurements on constant time interval, meanwhile it do some calculation on the measurments)
> > how do i do it?

Subject: Timing in matlab simulation

From: Pieter Chys

Date: 8 Oct, 2010 13:10:05

Message: 4 of 4

Hello Michael,

In that case you maybe need to introduce time as a variable in your
computations without being bothered what the actual computational
times are. Then, you just have to make sure that your model and
constants are physically correct. When that is the case you sample
at a constant interval of your time variable in the program.

Pieter.



"michael" <bezenchu@gmail.com> wrote in message <i8mdhs$qfs$1@fred.mathworks.com>...
> but when i do the pause, i can't do other calculations
> for example - i wanna calculate speed of rotation of car wheel:
> each second there is sampling.
> after the taking some sample till next sample there should be time (less then second because the duration of the taking the sample) in which i want to do some calculations.
> according your proposal - i can't
>
> "Pieter Chys" <pieter@cib.csic.es> wrote in message <i89lge$orq$1@fred.mathworks.com>...
> > Hello Michael,
> >
> > You could use:
> >
> > pause on
> > for i = 1:n
> > pause(n)
> > your simulation function....
> >
> > end
> >
> > with n a nonnegative real number (when the time
> > interval is not too small because for high resolution
> > there can be high relative error). If exactness is
> > important at small time scales you should check out
> > info on 'time and date operations' at Mathworks
> > Matlab info pages. It is certainly possible.
> >
> > Regards,
> > Pieter Chys.
> >
> > "michael" <bezenchu@gmail.com> wrote in message <i7vrd1$njl$1@fred.mathworks.com>...
> > > hello
> > >
> > > for my simulation, i need to do timing - a function to run on constant time delays, no matter what (for example during the simulation, the program should do measurements on constant time interval, meanwhile it do some calculation on the measurments)
> > > how do i do it?

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