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?

 採用された回答

MathWorks Support Team
MathWorks Support Team 2026 年 5 月 6 日 0:00
編集済み: MathWorks Support Team 15分 前
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.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeModeling についてさらに検索

製品

リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by