How to set/assign a value to Subsystem inports from .m file?

5 visualizaciones (últimos 30 días)
Ramesh Akula
Ramesh Akula el 8 de Oct. de 2020
Respondida: Sameer el 8 de Mayo de 2025
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".

Respuestas (1)

Sameer
Sameer el 8 de Mayo de 2025
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!

Categorías

Más información sobre Subsystems en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by