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

4 次查看(过去 30 天)
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!

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by