Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Help with Matrix Summations
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi,
Below is an output from matlab. I wish to combine this into one matrix & add the three last terms of each elg_nl to the first three in the next elg_nl. How can this be done? The required solution is shown. I may also have more than 3 elg_nl, would I require a loop??
>> elg_nl
elg_nl(:,:,1) =
0
0
0
-6
-3
1
elg_nl(:,:,2) =
-5.0000
0.0000
7.5000
-5.0000
0.0000
7.5000
elg_nl(:,:,3) =
-6
-3
1
0
0
0
>> expected result (12x1matrix)
0
0
0
-11.0000
-3.0000
8.5000
-11.0000
-3.0000
8.5000
0
0
0
Please help, thanks
댓글 수: 0
답변 (2개)
Matt J
2014년 1월 27일
sum(elg_nl,3)
will produce the middle 6 elements you want. I don't know by what you rule you want it extended to 12x1, unless it's just zero padding.
댓글 수: 2
Amit
2014년 1월 27일
eigen_nl_expected = [eigen_nl(:,:,1);eigen_nl(:,:,3)]
eigen_nl_expected(4:9) = eigen_nl_expected(4:9) + eigen_nl(:,:,2);
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!