Pairwise subtraction of rows in the same matrix
Show older comments
Hello guys...
Please I have this code
How can I subtract each row from all other rows(R) ... like subtracting R1-R1; R1-R2, R1-R3... R1-Rn+1 AND
then R2-R1, R2-R3.... R2-Rn+1 for all the rows
A1 = [...
0 0 1 1 1
0 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
0 0 1 1 1
1 0 1 0 1
0 0 0 0 1
1 1 1 1 1
1 1 1 1 1
0 1 1 1 1
1 0 1 0 1
0 0 1 0 1
1 1 1 1 1
1 1 1 1 1
1 0 1 1 1
0 0 1 1 1
0 1 1 1 1
1 1 1 1 1];
I need this urgently....
Thanks
6 Comments
per isakson
on 11 May 2019
Is the expected result one matrix of the same size as A1 ?
David Goodmanson
on 11 May 2019
Edited: David Goodmanson
on 12 May 2019
Hi Adedeji,
In the more recent versions of Matlab the expression
A - A(:,n)
conveniently subtracts the nth column of A from each and every column of A.
[comment intended to provide an expression that could be used as a building block]
Adedeji
on 12 May 2019
Image Analyst
on 12 May 2019
Why do you need this quirky thing? Is it homework?
Have you tried diff()?
Adedeji
on 12 May 2019
Adedeji
on 12 May 2019
Accepted Answer
More Answers (0)
Categories
Find more on Operators and Elementary Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!