set base workspace variable from callback

4 ビュー (過去 30 日間)
ander
ander 2015 年 5 月 29 日
コメント済み: Image Analyst 2015 年 5 月 29 日
Good morning, I am trying to set one variable of the base workspace from a pushbutton callback. I tried with assign but it isn`t possible because when I am in the callback the variable doesn`t exist. When I get out of the callback I see the variable in the workspace but it hasn`t changed.
Thanks in advance!

回答 (1 件)

Image Analyst
Image Analyst 2015 年 5 月 29 日
You need to use "assignin()" - is that what you used? If you did, then what was your code? Why do you want to do that anyway, instead of using normal ways of passing variables?
  2 件のコメント
ander
ander 2015 年 5 月 29 日
Thanks for the answer, yes I use that. Look the problem is that when I start the simulation the simulink model use the 'base' workspace, but when I push the button and enter in the pushbutton callback the workspace 'base' doesn`t exist, so it is imposible to change the value. Finally when I am out of the callback the workspace 'base' exist but it doesn`t change. I don`t know other form to do that.
Image Analyst
Image Analyst 2015 年 5 月 29 日
I don't know Simulink but in MATLAB, that's not how you're supposed to do it. You're supposed to pass variables in and out via the input and output argument lists. Can you do that in Simulink?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeModel, Block, and Port Callbacks についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by