simulink mask text cannot access matlab workspace
4 ビュー (過去 30 日間)
古いコメントを表示
Amish Rughoonundon
2016 年 2 月 29 日
回答済み: Sebastian Castro
2016 年 3 月 1 日
Hi, in mask editor's Icon & Ports, I tried using the text drawing command to display a string that is in my workspace. Simulink is giving me an error for that. What am I doing wrong? Amish
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/156320/image.jpeg)
0 件のコメント
採用された回答
Sebastian Castro
2016 年 3 月 1 日
Masks, by design, have their own separate workspace so there is no conflict between internal variables to a block and anything you do outside of that. So, you cannot directly read from the MATLAB base workspace.
The first question I would ask myself is: Why does that text need to exist in the base workspace? This can affect the robustness of your mask display code because anyone (or anything) could overwrite or delete that text and break your block. Please consider avoiding the base workspace for that reason.
If you're doing something where several blocks need to "share" this variable, then the base workspace becomes more of a viable option to temporarily store a variable. If so, you can use the evalin function to pick an expression from the base workspace and use it in your mask's "Initialization" tab.
revString = evalin('base','revString')
Once you do that, you have a variable called revString also in the mask, which pulls from whatever the expression revString evaluated to in the base workspace.
- Sebastian
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Author Block Masks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!