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!