Segmenting a large data set into a subset then sequencing the subset
이전 댓글 표시
Dear Matlab Answers!
I have a segmentation problem within Matlab.
I’ve imported using swallow_csv (which is amazing) a large sequenced data set. The dataset is imported as a variable called numbers which is a 44320x102 double.
Now I can already produce a new variable called rowsGrasp which is a subset of numbers which puts the whole lines into the new variable when a grasp is detected (column 11. Either 0 or 1).
This is achieved with : rowsGrasp = numbers(numbers( :,11) == 1, :);
What I would like to do is from numbers produce a new variable (graspReleaseSequence) which takes the first row instance of grasp ( so the 11th column value is 1) in the numbers variable all the way down to the last row instance of grasp where the value is 1.
With this new variable what I would like to do is to add another column which sequences from 1 onwards when the grasp value changes. So if the first 6 rows of graspReleaseSequence’s grasp value = 1 then the new column (called sequenceNumber is 1) when the row with grasp type = 0 starts the sequenceNumber value would be 2 (say for 8 rows) until the row with grasp = 1 then it switches to sequenceNumber 3. And so on until the bottom of the variable.
What would be the best way of doing this?
Any pointers would be gladly appreciated!
Thanks,
Peter
댓글 수: 2
Peter Snow
2017년 6월 21일
"I'm thinking this might be easier to do in python then import it into Matlab!"
Really? Why would that be easier?
What would help us most to help you is when you provide a complete set of example input and output data (this does not need to be the real data, just something with the same properties): then we can test our answer code and show that it does what you want.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

