Doing arithmatic to specific rows of a matrix

1 view (last 30 days)
I have this matrix in part a) called Mat1 and for part c) I need to do different arithmatic opertations to individual rows. How would I go about doing this? I can only seem to do it for the whole matrix.

Accepted Answer

Voss
Voss on 5 Feb 2023
Edited: Voss on 5 Feb 2023
Here's an example that adds 6 to the second row of a matrix M:
% define M
M = [1 2 3; 4 5 6; 7 8 9]
M = 3×3
1 2 3 4 5 6 7 8 9
% add 6 to the second row of M
M(2,:) = M(2,:) + 6
M = 3×3
1 2 3 10 11 12 7 8 9

More Answers (0)

Categories

Find more on Operating on Diagonal Matrices in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!