MATLAB: Extract a portion of vector

vector

Hi, I have a problem that I can not solve.
I need to extract a portion of my vector, this vector has 2 columns (first column is time and second is wave height) and 2500 rows, the values of the second column are number and NaN, the data are sampled every 3 hours. The problem is: I need to create a new vector that contains only the registration longer than 20 hours, and for the rest I must to replace with NaN.
Here an example:
Initial vector= [0 0.2
3 0.35
6 NaN
9 NaN
12 NaN
15 NaN
18 NaN
21 NaN
24 0.29
27 0
30 0
33 0
36 0
39 0
42 0
45 0.18
48 0.33
51 NaN
54 NaN
57 NaN]
The result should be
[0 NaN
3 NaN
6 NaN
9 NaN
12 NaN
15 NaN
18 NaN
21 NaN
24 0.29
27 0
30 0
33 0
36 0
39 0
42 0
45 0.18
48 0.33
51 NaN
54 NaN
57 NaN]
Can anyone suggest an approach to solve this problem?
Thanking you in advance
Alessandro Antonini

Best Answer

I solve the problem with the help of my friend, I needed two while cicle.
to solution was:
C=impuct vector and e1=C(:,2), the code is:
i=1;
while i<length(e1)
j=0;
i
while isnan(e1(i+j))==0 && (i+j)<length(e1)
j=j+1;
end
if j<7
e1(i:(i+j-1))=NaN;
end
i=i+j+1;
end