Doing arithmatic to specific rows of a matrix

1 vue (au cours des 30 derniers jours)
Connor
Connor le 5 Fév 2023
Commenté : Connor le 5 Fév 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.

Réponse acceptée

Voss
Voss le 5 Fév 2023
Modifié(e) : Voss le 5 Fév 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

Plus de réponses (0)

Catégories

En savoir plus sur Operating on Diagonal Matrices dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by