Separate the positive values from the negative values
7 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
採用された回答
madhan ravi
2019 年 1 月 11 日
編集済み: madhan ravi
2019 年 1 月 11 日
Xp=X(X>0)
Xn=X(X<0)
Xn=abs(Xn)
4 件のコメント
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 Center および File Exchange で Array and Matrix Mathematics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!