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

조회 수: 3 (최근 30일)
HAAAAH
HAAAAH 2019년 1월 28일
답변: Adam 2019년 1월 28일
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
Adam
Adam 2019년 1월 28일
편집: Adam 2019년 1월 28일
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).

댓글을 달려면 로그인하십시오.

채택된 답변

Adam
Adam 2019년 1월 28일
vny = v;
vny( 2:2:end) = -vny( 2:2:end);
should work

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by