Create index vector from grouping variable based on a condition
显示 更早的评论
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
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Tables 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!