Segmenting an original .mat file

2 次查看(过去 30 天)
Rosie
Rosie 2017-3-17
评论: Rik 2017-3-17
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 个评论
Rik
Rik 2017-3-17
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,:);

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by