Doing arithmatic to specific rows of a matrix

1 Ansicht (letzte 30 Tage)
Connor
Connor am 5 Feb. 2023
Kommentiert: Connor am 5 Feb. 2023
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.

Akzeptierte Antwort

Voss
Voss am 5 Feb. 2023
Bearbeitet: Voss am 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

Weitere Antworten (0)

Kategorien

Mehr zu Operating on Diagonal Matrices finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by