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

4 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

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

Più risposte (0)

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by