Making part of a column negative depending on another column
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello,
I am trying to do the following. I have two column vectors as follows:
a=[3;5;8;2;-2;-5;-8];
b=[1;2;3;4;5;6;7];
I am trying to make the values of b corresponding to the locations of a negative in a, negative. so the result would be
b_new=[1;2;3;4;-5;-6;-7]
The last three values of b would be changed to negative because the last three values of a are negative. Both column vectors are the same length.
댓글 수: 1
Walter Roberson
2013년 9월 11일
What is the difference between this question and your earlier http://www.mathworks.co.uk/matlabcentral/answers/86609-converting-positives-to-negatives-in-a-column ?
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!