How to get matrix data from function ,anyone help me
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
PRED LIU
am 2 Mai 2020
Kommentiert: Walter Roberson
am 2 Mai 2020
Z=[ 1 3 4 ;5 3 1;3 3 3];
a=1;
Qa=example(a,Z);
ss=Qa(1)+Qa(2); %=====> I CAN'T get both matrix data a+Z and a*Z
%%
%%%my function building as such
function dBB=example(a,Z)
dBB(1)= Z+Z;
dBB(2)=Z+Z+Z+Z+Z;
%%%%%%
0 Kommentare
Akzeptierte Antwort
James Tursa
am 2 Mai 2020
Bearbeitet: James Tursa
am 2 Mai 2020
Not sure what the real question is. Maybe this does what you want?
function [apZ,atZ]=example(a,Z)
apZ = a + Z;
atZ = a * Z;
end
and you would call it like this
[x,y] = example(a,Z);
2 Kommentare
Walter Roberson
am 2 Mai 2020
[apZ, atZ] = example(a,Z);
answer = sqrt(apZ.^2 + atZ.^2);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices 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!