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

2 views (last 30 days)
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 Comment
Adam
Adam on 28 Jan 2019
Edited: Adam on 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).

Sign in to comment.

Accepted Answer

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

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!