フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

there is a problem about these code in Matlab

1 回表示 (過去 30 日間)
vx2008
vx2008 2013 年 3 月 20 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
code is as below:
function [y1,y2]=test(x1,x2)
if nargin==1
y1=x1;
if nargout==2
y2=x1;
end
else
if nargout==1
y1=x1+x2;
else
y1=x1;
y2=x2
end
end
after that, I execute the command as below: [x,y]=test(3,6)
then I get the result as below: y2=6 x=3 y=6
But my expect result shoud be: x=3 y=6
why does y2 come out here?

回答 (1 件)

Carlos
Carlos 2013 年 3 月 20 日
Try
function [y1,y2]=test(x1,x2)
if nargin==1
y1=x1;
if nargout==2
y2=x1;
end
else
if nargout==1
y1=x1+x2;
else
y1=x1;
y2=x2;
end
end
  2 件のコメント
Carlos
Carlos 2013 年 3 月 20 日
y2=x2; instead of y2=x2
vx2008
vx2008 2013 年 3 月 20 日
exactly,thanks

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by