Subtract rows in matrix using loop

1 次查看(过去 30 天)
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
Use diff:
diff(UVI_all_am,1,1)
And stick a row of zeros along the top if you really need row1 - row1.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by