how to make function that sometimes return output and how to call
1 回表示 (過去 30 日間)
古いコメントを表示
besbesmany besbesmany
2017 年 10 月 22 日
コメント済み: besbesmany besbesmany
2017 年 10 月 22 日
- b sometimes returned from myfn and sometimes not returned, so how to write the function that may retrun b
function [a,b] = myfn(x,y)
a
if(x=y)
b
end
- also how to call myfn from the main file if b is not returned
[a,b]=myfn(x,y)
0 件のコメント
採用された回答
Stephen23
2017 年 10 月 22 日
Simplest solution: set a default output value:
function [a,b] = myfn(x,y)
a = 1;
b = [];
if(x=y)
b = 2;
end
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!