Create index vector from grouping variable based on a condition
Afficher commentaires plus anciens
Hey!
I have a table with x variables that very in sign from - to +. I want to create a third column t.count in a table that includes -1 index for every negative x value, 0 for 0 and +1 for the positive x-values. The only similar command that I know is grip2idx but it doesn't do what I need in this case. Is there a way to do it ithout a for-loop?
x = [0 0.5 0.6 1 -0.03 -0.6 -0.8 0 0]'
y = [1:1:length(x)]'
t = table
t.x = x
t.y = y
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Tables 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!