Two separate outputs from one input
5 ビュー (過去 30 日間)
古いコメントを表示
Need help trying to write a code that would take one single input and provide two separate outputs
"Write a function that takes a single number a, and returns a*2 and a+2 as two separate output arguments."
0 件のコメント
回答 (1 件)
Viranch Patel
2021 年 9 月 22 日
You can have multiple outputs from the function like this.
function [multiply,sum] = test(x)
multiply = x*2;
sum = x+2;
end
And after that you can call the function in following manner.
[multiply, sum] = test(x);
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!