Hi, I have a 11 x 3541 matrix. For each column I want subtract; row1 from row1 then,row1 from row 2 then, row2 from row 3 and so on. I have tried using a loop but it doesn't work.
for i= 0:12
mono_am = UVI_all_am(1+i,:) - UVI_all_am(i+1-i,:);
end

 채택된 답변

Stephen23
Stephen23 2017년 5월 11일
편집: Stephen23 2017년 5월 11일

0 개 추천

Use diff:
diff(UVI_all_am,1,1)
And stick a row of zeros along the top if you really need row1 - row1.

댓글 수: 3

David du Preez
David du Preez 2017년 5월 11일
How can I add the row off zeros to the first line if the matrix has already been made ?
X = diff(UVI_all_am,1,1);
X = [zeros(1,size(X,2));X];
David du Preez
David du Preez 2017년 5월 11일
Thanks

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2017년 5월 11일

댓글:

2017년 5월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by