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

4 views (last 30 days)
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!

Accepted Answer

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

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!