How to use variable of function in the main program
2 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
I have a main program Main.m. In the main I call a function [a,b,c]=func(data), I would like now to use the output a in the Main.m. how can I do it ?
Thanks for the help.
0 件のコメント
回答 (1 件)
dpb
2014 年 8 月 2 日
編集済み: dpb
2014 年 8 月 2 日
... I call a function [a,b,c]=func(data),...
So, then you have a in the calling workspace (as well as b and c); so you just reference them as any other variable. Presuming, of course, that func doesn't error when called with data.
% script continues from above...
[a,b,c]=func(data);
fprintf('Asuitableformatstring',a) % display the result variable a or any other use
...
4 件のコメント
Star Strider
2014 年 8 月 2 日
... speaking of which, using sprintf or fprintf might also eliminate some frustration.
参考
カテゴリ
Help Center および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!