Matlab row subtraction of matrix
Show older comments
Matlab subtractions of rows of matrix(eg:- row2-row1) and then how to rewrite the resulatant entire matrix where 2nd row = row2 - row1
Accepted Answer
More Answers (1)
Paul Hoffrichter
on 30 Jan 2021
I am taking a guess as to what you want. Would be nice if you gave a simple matrix, A, and showed the desired result. But here is my guess about how to subtract adjacent rows.
>> A = [ 1 2 3 4; 11 12 13 14; 22 23 24 25; 42 43 44 45]
A =
1 2 3 4
11 12 13 14
22 23 24 25
42 43 44 45
>> Adf = diff(A)
Adf =
10 10 10 10
11 11 11 11
20 20 20 20
2 Comments
Virendra Kowale
on 30 Jan 2021
Paul Hoffrichter
on 30 Jan 2021
A = [ 1 2 3 4; 11 12 13 14; 22 23 24 25; 42 43 44 45];
B = myFunction(A);
I am not sure what you want. row' = row2 - row1. row' on the left hand side of an = sign is incorrect. Please write down what the values in B should be for the input matrix A.
Categories
Find more on Creating and Concatenating Matrices 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!