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

3 Ansichten (letzte 30 Tage)
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!

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by