How can I get real time value from the Simulink scope plot to use inside the MATLAB function block ?

39 ビュー (過去 30 日間)
I want to use the value of one plot from simulink inside the matlab function block. For example for t>40, g_initial=g(40), where g(40) is the value of function g at time instant 40. Even at time instant 80, I want to use the same initial condition. But I am not able to do that.

回答 (2 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 5 月 27 日
Hi,
(1) You would need to simulate your simulink model inside your matlab script that can be done with sin() that you have probably employed already.
(2) Use the output values from your [Scope] or signal going to [Scope] via [To Workspace] block.
(3) Proceed with the acquired signal. Since you're intending to use specific values acquired from Simulink model that can be manipulated with logical indexing or conditional statement opeators, etc.
  1 件のコメント
pritesh patel
pritesh patel 2021 年 5 月 28 日
I am able to get the signal value in the work space... but when I am using that value inside the matlab script, ir is showing error.

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


Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 5 月 28 日
Hi,
if you have employed [To Workspace] block, you can use this syntax within your m-file:
OUT = sim('ABC.slx'); % Simulink model called ABC.slx and Output variable name: OUT
plot(OUT.tout, OUT.simout)
Good luck.

カテゴリ

Help Center および File ExchangeScopes and Data Logging についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by