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에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by