conversion from simulation time to real time

hello ... i have a simulink program with fixed step size (0.001),, i run the program in time (0-300) ,, and when i want to plot my results, the "time axis" is the simulation time (not the real time) ... i.e. this 300 (simulation time) equal almost 1 minutes (in real word) ... how can i convert this 300 to 60 second to make the results in real time ?

1 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 4 月 5 日
You mean at the end of the simulation?

サインインしてコメントする。

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 4 月 5 日

0 投票

Look at this example
t=0:300
y=sin(0.1*t)
tn=60;
t_new=linspace(0,60,numel(t))
plot(t_new,y)

9 件のコメント

cmcm
cmcm 2014 年 4 月 5 日
編集済み: cmcm 2014 年 4 月 5 日
thank you but there is some problems firstly.. my program is (simulink) not (M-file), and i already have the (clock) block that count the simulation time in my program... so, i did not need the two steps at the beginning... secondly, the time is "almost" 60 seconds, and if i let the simulation time more than (300) then it will be more than (60 sec.)... so i need some thing variable not fixed to 300 and 60
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 4 月 5 日
I have understood you are running a Simulink model, that's why I've asked if you want to plot after simulation or during. Now what you are asking for is not clear, set the stop time to 300 then change it to 60, how? and what is your aim?
cmcm
cmcm 2014 年 4 月 5 日
編集済み: cmcm 2014 年 4 月 5 日
because when i plot my results ... i need it to be real time not simulation time ... the (300 ) or what ever was the stop time it will always be the simulation time (which is so fast in compare with the real world)... in other words, i need to convert this simulation time to be similar to real time in real world ... get it now ??
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 4 月 5 日
編集済み: Azzi Abdelmalek 2014 年 4 月 5 日
If you want to make a simulation in real time, you can use a real time windows target . If you haven't this toolbox, you can use pause command
cmcm
cmcm 2014 年 4 月 5 日
real time windows target is bout building a new real time system not only conversion :(
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 4 月 5 日
No you can do many things with RTWT, You can control a real system. In your case, you can just make a simulation in a real time (60 s will be almost 60 s), this is possible if the calculation time doesn't exceed your step time, you can get better behaviour with simulation in external mode.
cmcm
cmcm 2014 年 4 月 5 日
I do not have any background on how to deal with real time windows target
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 4 月 5 日
編集済み: Azzi Abdelmalek 2014 年 4 月 5 日
If you have the toolbox, just read the help, it's easy to use
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 4 月 5 日
To use the external mode, you will need also, a Simulink coder

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeEvent Functions についてさらに検索

質問済み:

2014 年 4 月 5 日

コメント済み:

2014 年 4 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by