How can I import variables from a Simulink Model Workspace to my MATLAB workspace?

3 ビュー (過去 30 日間)
Hansi K
Hansi K 2025 年 3 月 22 日
回答済み: Paul 2025 年 3 月 22 日
I want to execute a Simulink model in calculations.mlx and want to export variables from the Simulink model workspace to the calculations.mlx workspace. How can I do this? I run the model using sim('Ex2_366_113.slx'); but this doesn't import the variables I used for my simulation. I don't want to open the Simulink model for this.
v

採用された回答

Paul
Paul 2025 年 3 月 22 日
Hi Hansi,
Use get_param to create a handle the model workspace, and then loop over the variables in the model workspace and assign them to local variables, e.g., fields in a struct, in the script using the whos and getVariable object functions. See Simulink.ModelWorkspace and links from that page for more details.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by