How to modify one line of a matrix and get the entire matrix for result within the modification?

2 visualizaciones (últimos 30 días)
Hi,
For example I have : x = [ 1 2 3; 4 5 6]
If I want to have 1 2 3 multiplies by -1, how can I do? I want to get [-1 -2 -3; 4 5 6] for answer.
Because right now I am only able to do x(1, :)*-1 which gives me [-1 -2 -3]
Thanks!

Respuesta aceptada

Jonas
Jonas el 30 de Jun. de 2021
just assign the values like that:
x=[1 2 3; 4 5 6];
x(1,:)=-x(1,:)

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by