How to do computation in local function?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Image Analyst
am 16 Feb. 2022
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?
2 Kommentare
Siehe auch
Kategorien
Mehr zu Entering Commands finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!