Doing arithmatic to specific rows of a matrix

1 visualización (últimos 30 días)
Connor
Connor el 5 de Feb. de 2023
Comentada: Connor el 5 de Feb. de 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.

Respuesta aceptada

Voss
Voss el 5 de Feb. de 2023
Editada: Voss el 5 de Feb. de 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

Más respuestas (0)

Categorías

Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by