How to change a sign of elements in a matrix for each coulmn separatly ?

2 Ansichten (letzte 30 Tage)
I want to change
v = [-2 3 0.5 4 22 15 -19 -0.01 104 78]
to
vny = [-2 -3 0.5 -4 22 -15 -19 0.01 104 -78]
thanks for tips
  1 Kommentar
Adam
Adam am 28 Jan. 2019
Bearbeitet: Adam am 28 Jan. 2019
What is the logic behind which columns you want to change? Just every other column? If there is none then obviously you will have to do it manually (or at least create a multiplier array manually).

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Adam
Adam am 28 Jan. 2019
vny = v;
vny( 2:2:end) = -vny( 2:2:end);
should work

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by