Subtracting every other row

3 ビュー (過去 30 日間)
Jessica Thomas
Jessica Thomas 2016 年 7 月 29 日
回答済み: James Tursa 2016 年 7 月 29 日
Hi,
I have a 9x2 matrix.
A= [0.08 2; 0.03 2; 0.04 2; 0.05 1; 0.07 1; 0.04 1; 0.02 1; 0.03 2; 0.08 2]
I want to subtract the value in row 3 column 1 by row 2 column 1, and then i want to subtract row 5 column 1 by row 4, and then i want to subtract row 7 column 1 by row 6 column 1, and so on.
In the end I want a matrix that looks like this: B= [0.01; 0.02; -0.02; 0.05]

採用された回答

James Tursa
James Tursa 2016 年 7 月 29 日
B = A(3:2:end,1) - A(2:2:end,1);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by