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?

 Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 6 de Mayo de 2026 a las 0:00
Editada: MathWorks Support Team el 8 de Mayo de 2026 a las 13:33
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.

Más respuestas (0)

Categorías

Más información sobre Modeling en Centro de ayuda y File Exchange.

Productos

Versión

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by