How do I declare a variable in the MATLAB workspace from a MATLAB function?
古いコメントを表示
I wrote a function that provides some variables to Simulink. I have declared them global, so Simulink could see them. But I have to declare them at the prompt and I am unable to declare them in the function because Simulink does not see them.
採用された回答
その他の回答 (1 件)
Gaganjyoti Baishya
2020 年 6 月 20 日
0 投票
Hi,
You can easily add variables in base from function using assignin.
function myFunc(a,b)
x=3;
assignin('base','myVar',x);
end
assignin declares the varibale myVar with value of 3.
カテゴリ
ヘルプ センター および File Exchange で Workspace Variables and MAT Files についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!