- Save this function as fun1.m file in separate MATLAB file.
- Once required, call the function from the mainn code or command widow with passing appropriate A vector data.
Function writing for variable matrix
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Cside
am 3 Okt. 2020
Kommentiert: Cside
am 3 Okt. 2020
Hi i currently have this code and would like to write a function for it. I have to run this function with matrixes labelled A to D. How can I write for this function such that when I input A, B or C at that position, it would give me agem and agestd for the matrix entered?
Thank you!
agem = mean(A(:,6));
agestd = std(A(:,6));
function [agem,agestd]
0 Kommentare
Akzeptierte Antwort
KALYAN ACHARJYA
am 3 Okt. 2020
Bearbeitet: KALYAN ACHARJYA
am 3 Okt. 2020
" write for this function such that when I input A, B or C at that position"
Please note: In the function defination, only A is there
function [agem,agestd]=fun1(A)
agem = mean(A(:,6));
agestd = std(A(:,6));
end
Steps:
From the command window, you can verify the same
>> mat=magic(6);
>> [agem,agested]=fun11(mat)
agem =
18.5000
agested =
5.4681
>>
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!