How do I create a matrix such as a matrix L of the data matrix M as shown below..?
조회 수: 2 (최근 30일)
이전 댓글 표시
I have matrix M below
M = [1 2 0.2
2 3 0.4
3 4 0.22
4 5 0.1
5 6 0.5]
How do I create a matrix such as a matrix L of the data matrix M as shown below..?
L = [0.2
(0.4+0.2)
(0.22+0.4+0.2)
(0.1+0.22+0.4+0.2)
(0.5+0.1+0.22+0.4+0.2)
]
댓글 수: 0
채택된 답변
Image Analyst
2017년 1월 2일
Try this:
L = cumsum(M(3:3:end))
댓글 수: 2
Image Analyst
2017년 1월 2일
편집: Image Analyst
2017년 1월 2일
Right. That's what I had in her original question (a separate discussion thread), which was a 2-D matrix. This question used to be a row vector. Now she changed this one from a row vector to a 2-D matrix and somehow her other question, with the 2-D matrix that I answered exactly like you did, is now gone.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!