MATLAB: Read certain range in csv file and save to new file

extract data

Hi guys,
I have a one column data contain 100 000 rows.
i need to extract a data for range 0-0 and save it into new file.
example of my data:
0
1
2
3
4
5
0
6
7
4
3
5
6
0
6
43
5
7
5
0
7
4
60
0
Then, for a new file it should contains 0 1 2 3 4 5 0 in column , the second file is 0 6 7 4 3 5 6 0 and so on.

Best Answer

A loop is the only (and likely the simplest) option, since you need the zero values on both ends of each sub-vector:
V = [0
1
2
3
4
5
0
6
7
4
3
5
6
0
6
43
5
7
5
0
7
4
60
0];
idx = find(V == 0);
for k1 = 1:numel(idx)-1
Out{k1} = V(idx(k1):idx(k1+1));
end