How to do computation in local function?
이전 댓글 표시
function [a,b] = c(d,e)
a = d+e;
b = d.*e;
The following MATLAB script utilizes a local function and the c function mentioned above. Compute the final value of vector a. Please show how you obtained your answer. Could someone explain it how to get a briefly? Thank you in advance.
a = [1 2];
a = compute(a);
function a = compute(b)
[a,b] = c(b,b);
end
댓글 수: 3
Geoff Hayes
2022년 2월 16일
@Sam Yeoh what exactly is your question? Have you tried to run the above code to see what the output is?
Sam Yeoh
2022년 2월 16일
Geoff Hayes
2022년 2월 16일
Isn't "the final value of a" the output of the compute function?
답변 (1개)
a = [1 2];
a = compute(a)
function a = compute(b)
[a,b] = c(b,b);
end
function [a,b] = c(d,e)
a = d+e;
b = d.*e;
end
Not sure what you consider the "final value of a". Do you mean a(end), which would be 4?
카테고리
도움말 센터 및 File Exchange에서 Entering Commands에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!