필터 지우기
필터 지우기

How to use variable of function in the main program

조회 수: 2 (최근 30일)
Adam
Adam 2014년 8월 2일
댓글: dpb 2014년 8월 2일
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.

답변 (1개)

dpb
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
Star Strider 2014년 8월 2일
... speaking of which, using sprintf or fprintf might also eliminate some frustration.
dpb
dpb 2014년 8월 2일
good catch...and also a chuckle... :)

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by