How to update .mat file in simulink.

1 回表示 (過去 30 日間)
Nishant Kumar
Nishant Kumar 2020 年 3 月 30 日
回答済み: Rohit Pappu 2020 年 9 月 4 日
Hello,
I have a Matlab function block which loads a variable from a .mat file and work on it. I then updates the variable and then returns the value to a 'To File' block in simulink which saves the variable by the same name.
But every time I run the simulation, it creates a new .mat file by the same name with null value. Is there a solution for that?
I want to access the variable, change its value and then save it again by the same name.
Thanks for the help.
  1 件のコメント
Fangjun Jiang
Fangjun Jiang 2020 年 3 月 30 日
What is the reason running it in Simulink? Keep in mind that the MATLAB Function block is executed every simulation step, e.g. 0.01 seconds.

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

回答 (1 件)

Rohit Pappu
Rohit Pappu 2020 年 9 月 4 日
To File block creates a duplicate file every time the simulation happens.
A possible workaround would be to use Input and Output blocks instead.
  • Assign the same variable names to both input and output.
  • Load and Save the MAT-file containing the variables using callback functions.

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by