How to set/assign a value to Subsystem inports from .m file?
5 ビュー (過去 30 日間)
古いコメントを表示
I would like to assign a value to Simulink Subsystem inports from .m file. Is it possible to do this in Simulink? Idea is to check Subsytem functionality independent from other subsytems. I know that its possible by using "Simulink Test" but I am would like to do with .m or any other custom file without using "Simulink Test".
0 件のコメント
回答 (1 件)
Sameer
2025 年 5 月 8 日
Yes, you can assign values to Simulink Subsystem inports from an '.m' file, without needing Simulink Test.
The easiest way is to use "From Workspace" blocks in place of the Inport blocks inside your subsystem. Here’s how:
1. Replace the Inport block in your subsystem with a From Workspace block.
2. In your '.m' file, define the input signal as a variable (for example, using a timeseries object)
t = (0:0.01:10)';
u = sin(t);
input_signal = timeseries(u, t);
3. Set the From Workspace block's variable name to "input_signal".
Now, when you run your model, the subsystem will use the signal you defined in your '.m' file as its input. This lets you test your subsystem independently from the rest of the model.
Please refer to the following MathWorks documentation link:
Hope this helps!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Subsystems についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!