Suppressing only part of a function output?

If I were to have a function in the form [a,b,c] = myFun(d,e), and I wanted to call the function in a script and have all three output values, (a,b,c) in the workspace, but only a and b printed to the command window how could i accomplish that?
Thanks for any help.

답변 (1개)

Star Strider
Star Strider 2020년 4월 4일

0 개 추천

To have only ‘a’ and ‘b’ returned:
[a,b] = myFun(d,e)
and to have only ‘c’ returned:
[~,~,c] = myFun(d,e)
Use variations on this idea to return whatever outputs you want.
This is described in: Ignore Function Outputs

댓글 수: 2

I understand how this concept works, but I still need the values for all 3 outputs to be stored in the workspace, it's just that I only want the first two to print to the command window
[a,b,c] = myFun(d,e);
a
b

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

카테고리

도움말 센터File Exchange에서 Entering Commands에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2020년 4월 4일

댓글:

2020년 4월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by