pause() function not running in realtime

I am working on a project that modelise the DC motor with the following state-space form:
Here is my code: ------------------------------------
------------------------ Result:
----------------------- My goal is that I want to plot the value of the velocity which is theta dot versus realtime, so I use the pause() function in each step to represent real time simulation. However, I notice that this the plot is way slower than the real time. I am aiming to use mfile only, not simulink. My questions: - I am new to state-space and transfer function. Can you check the result for me? :D - Why is the points on the plot slower than the real time? Can anyone explain for me? What should I do if I want to fix it. Thanks very much for any response. I am really appreciated :D

1 件のコメント

VBBV
VBBV 2024 年 3 月 3 日
編集済み: VBBV 2024 年 3 月 3 日
% after the for loop
hold on
yyaxis right
sys = ss(A,B,C,D)
step(sys)

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

回答 (1 件)

VBBV
VBBV 2024 年 3 月 3 日
編集済み: VBBV 2024 年 3 月 3 日

0 投票

dt = 0.05
change the timestep size and try

2 件のコメント

VBBV
VBBV 2024 年 3 月 3 日
編集済み: VBBV 2024 年 3 月 3 日
use ss function https://in.mathworks.com/help/control/ref/ss.html to check/verify your results
Victor
Victor 2024 年 3 月 3 日
Thank you alot! I tried 0.1 s and it is actually closed to real time.

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

カテゴリ

製品

リリース

R2021b

質問済み:

2024 年 3 月 3 日

編集済み:

2024 年 3 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by