I have two vectors A and B obtained after MATLAB analysis. Both matrices have positive and negative values, starting from the same index. I want to replace all the negative values from let's say vector A with the corresponding positive values from vector B and vice-versa. How do I do that ?

댓글 수: 3

Paolo
Paolo 2018년 7월 12일
What happens when both A and B are negative at the same index?
And what happens if both are positive for that matter?
Why not take the maximum of both:
C = max(A, B);
dpb
dpb 2018년 7월 12일
편집: dpb 2018년 7월 12일
"... what happens if both are positive...?"
As OP wrote the problem description, nothing happens to A as it's nonnegative.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

질문:

2018년 7월 12일

편집:

dpb
2018년 7월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by