Please how can I unstack a column of negative and positive values into 2 columns of positive and negative values respectively?
Afficher commentaires plus anciens
sr=[-34;45;28;-10;-9]. s=sign(sr). I want to obtain sr1=[-34;-10;-9] and sr2=[45;28]
Réponse acceptée
Plus de réponses (1)
Jan Orwat
le 7 Juil 2016
You can compare your data with zero. This will classify your data and you can use it to get what you want.
Example based on your example data:
sr = [-34;45;28;-10;-9];
positive = (sr >= 0);
sr1 = sr(~positive); % ~ in Matlab represents negation
sr2 = sr(positive);
1 commentaire
Nadousse28
le 8 Juil 2016
Catégories
En savoir plus sur Data Type Conversion dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!