Summation of n-th columns of multiple matrix.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Aj
am 23 Feb. 2018
Beantwortet: Bhuvnesh Singh
am 26 Feb. 2018
I try to summate the 4th colums of this 15 matrices. I use following code:
P{1}=[0 18 0 0];
P{2}=[31 20 0 0];
P{3}=[51 25 0 0];
P{4}=[75 23.9 0 0];
P{5}=[76.2 25 0 1000];
P{6}=[84.7 25 0 1000];
P{7}=[93.2 31 0 1000];
P{8}=[109.2 46.7 0 1000];
P{9}=[127.2 49.7 0 1000];
P{10}=[145.2 31 0 1000];
P{11}=[161.2 25 0 0];
P{12}=[169.7 25 0 0];
P{13}=[178.2 23.9 0 0];
P{14}=[179.2 25 0 0];
P{15}=[188.4 25 0 0];
for k = 1 : 15
A{k} = P{k}(4)
y=sum(A{k})
end
Instead of y=6000 matlab show me that y=0. Maybe anyone show me my mistake.
0 Kommentare
Akzeptierte Antwort
Bhuvnesh Singh
am 26 Feb. 2018
To achieve this you can do something like :
y = 0
for k = 1 : 15
A{k} = P{k}(4)
y = y + A{k}
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!