Segmenting an original .mat file

2 views (last 30 days)
Rosie
Rosie on 17 Mar 2017
Commented: Rik on 17 Mar 2017
I have a .mat file with a data matrix (22 columns and 1780 rows). I also have a "marker" column (1 column and 1780 rows)with mostly 0s and then some other numbers. I want to segment this original .mat file as follows: -find odd positions of markers 2 and 3 in the marker column (for example the 1st, 3rd, and 5th "2"; and the same for 3)and the even positions of marker 6 (for example the second, 4th, and 6th position). -segment the .mat file so that data from odd position of marker 2 and the following even position of marker 6 are saved an another .mat file named XXX1 and data from the odd position of marker 3 and the even position of marker 6 that follows it are saved as another .mat file named xxx2...and so on.
-I don't know if this is possible or if it's easy or difficult to do this so any feedback is really appreciated!
  1 Comment
Rik
Rik on 17 Mar 2017
You can use logical indexing to do this. You could even auto-generate the filenames with sprintf, but I don't really see te system in your numbering. So you can select your data with
select_twos=find(marker==2);
select_odd_twos=select_twos(1:2:end);
selected_data=data(select_odd_twos,:);

Sign in to comment.

Answers (0)

Categories

Find more on Structures in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!