How to write a function with two kind of output modes?

How to write a function which can be used as y = myfunc(), or [y,z] = myfunc() ?

 채택된 답변

Star Strider
Star Strider 2016년 6월 24일
Write the first line as:
function [y,z] = myfunc()
If you only request one output, only the first output is returned by default.

댓글 수: 1

Sorry but you missunderstood my question. I mean two different kind of output mode. So I would like to generate different y if the sytax is: y1 = myfunc(), or [y2,z] = myfunc(). I s it possible?

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

추가 답변 (0개)

카테고리

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

질문:

2016년 6월 24일

댓글:

2017년 7월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by