Why does an output variable from a MATLAB Function block not update a model variable with the same name?

I am using MATLAB R2024b and defined an output variable in a MATLAB Function block that is outputted as a signal. I also defined a model variable with the same name. When the value of the output signal changes, the value of the model variable does not change.
Why is this happening?

 Akzeptierte Antwort

This is expected behavior. Like regular MATLAB functions, MATLAB Function blocks in Simulink have their own internal workspace. Signals output from a MATLAB Function block do not modify model variables, Simulink.Parameter objects, or variables in other workspaces (e.g., base or model), even if the names match.
More details on function workspaces can be found in the MATLAB Documentation on Base and Function Workspaces.

Weitere Antworten (0)

Kategorien

Mehr zu Modeling finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by