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

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

Accepted Answer

Star Strider
Star Strider on 24 Jun 2016
Write the first line as:
function [y,z] = myfunc()
If you only request one output, only the first output is returned by default.
  1 Comment
Mr M.
Mr M. on 17 Jul 2017
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?

Sign in to comment.

More Answers (0)

Categories

Find more on Denoising and Compression in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!