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 ?
Stephen23
Stephen23 2017 年 5 月 11 日
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 についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by