Summation of n-th columns of multiple matrix.

조회 수: 1 (최근 30일)
Aj
Aj 2018년 2월 23일
답변: Bhuvnesh Singh 2018년 2월 26일
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.

채택된 답변

Bhuvnesh Singh
Bhuvnesh Singh 2018년 2월 26일
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개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by