Hello ! can anybody tell me where am wrong.i have 179789 by 3 dimensions matrix. when am trying to get sum of all three axis to get one column vector the result is 1 by 179789 , but the desired result is 179789 by 1. looking for kind response
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Mirbahar Naadiya
am 16 Nov. 2017
Kommentiert: Mirbahar Naadiya
am 16 Nov. 2017
if true
% code
i=1
for i=1:m
acc(i)=sqrt((x(i)^2+y(i)^2+z(i)^2));
end
end
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 16 Nov. 2017
Bearbeitet: Andrei Bobrov
am 16 Nov. 2017
acc = zeros(m,1);
for ii = 1:m
acc(ii)=sqrt((x(ii)^2+y(ii)^2+z(ii)^2));
end
or
Let A - your array (179789 x 3)
acc = sqrt(sum(A.^2,2));
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Linear Algebra 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!