Subtraction between the rows of matrix
古いコメントを表示
I have a matrix A which is 880x100 and I want to do the subtraction between row to row.
For example
A= [ 1 1 1 1 ;2 2 2 2 ;.......880 880 880 880];
I want to take row 1- row 22, 2-21, ... row 11 -row 12, then row 12-row 33, row 13-row 32,.. row 22-row 23,
then row 23-row 44, ...row 34-row 55. The sum of row number minus other rows in the first 11 subtractions is 23 such as 22+1, 2+21. However, starting from row 12 - then the sum is 45 which is adding 22 to the 23, and then starting from 33 the sum is 67 which is 45+22, so on.
I was successfully doing for the first 11 but it is no longer valid after that.
for i =1:880
A(i,:)-A(23-i,:);
end
Anybody has an idea how to do this. Thanks.
採用された回答
その他の回答 (1 件)
michael scheinfeild
2015 年 2 月 26 日
just prepare the row index before as example :
a=[ 1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16]
a =
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
>>
c=[1 2]; d=[3 4]
d =
3 4
>> x=a(c,:)-a(d,:)
x =
-8 -8 -8 -8
-8 -8 -8 -8
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!