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

3 visualizzazioni (ultimi 30 giorni)
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 Commento
Adam
Adam il 28 Gen 2019
Modificato: Adam il 28 Gen 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).

Accedi per commentare.

Risposta accettata

Adam
Adam il 28 Gen 2019
vny = v;
vny( 2:2:end) = -vny( 2:2:end);
should work

Più risposte (0)

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by