Function ontput missed or not assigned
1 回表示 (過去 30 日間)
古いコメントを表示
Dear all,
I am confronted with a problem now. What I want to do is to formulate a function like
[y1,y2,y3]=f[x1,x2]
Note that the output and input dimensions are constant. Not all outputs will be assigned a value so in Matlab it will report an error. My question is that is there any method that I can assign values to the missed outputs outside when I call the function?
Thanks a lot
3 件のコメント
per isakson
2019 年 6 月 10 日
編集済み: per isakson
2019 年 6 月 10 日
"is there any method that I can assign values to the missed outputs outside [the function, f ]"
The simple answer is no - afaik.
回答 (1 件)
KSSV
2019 年 6 月 10 日
function [y1 y2]=xxx(u)
if u<10
y1=1 ;
y2= [] ;
else
y1 = [] ;
y2=1 ;
end
end
2 件のコメント
Walter Roberson
2019 年 6 月 10 日
No, there is no method to do that. You can use try/catch to handle the error more smoothly, but the error handling will be invoked before the outputs that are present are assigned.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!