Separate the positive values from the negative values

조회 수: 12 (최근 30일)
abdullah qasim
abdullah qasim 2019년 1월 11일
편집: madhan ravi 2019년 1월 11일
I have the following
X=[1 - 3 5 -8 4 9 -6 -3]
I want to separate the polarity ( positive values from the negative values) like this
Xp=[1 5 4 9]
Xn=[-3 -8 -6 -3]
then flip the negative values to positive values
like
Xn=[3 8 6 3]
then pass the values as a two-step
like
first, pass the positive step and the second pass the negative steps
NOTE : general methods

채택된 답변

madhan ravi
madhan ravi 2019년 1월 11일
편집: madhan ravi 2019년 1월 11일
Xp=X(X>0)
Xn=X(X<0)
Xn=abs(Xn)
  댓글 수: 4
abdullah qasim
abdullah qasim 2019년 1월 11일
any other way to make
Xfilp=XP+Xn
madhan ravi
madhan ravi 2019년 1월 11일
편집: madhan ravi 2019년 1월 11일
Xn=-Xn
Note : Only works if all the numbers are less than 0.
Xn(Xn<0)=-Xn(Xn<0) % alternate would work generally

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by