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

3 visualizaciones (últimos 30 días)
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 comentario
Adam
Adam el 28 de En. de 2019
Editada: Adam el 28 de En. de 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).

Iniciar sesión para comentar.

Respuesta aceptada

Adam
Adam el 28 de En. de 2019
vny = v;
vny( 2:2:end) = -vny( 2:2:end);
should work

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by