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!