I'm trying to find consecutive NAN's in a set of data and fill in the missing NAN's with it's closest known data point without interfering with the NAN's I've already filled in. So far the code I've written for the function is:
function [max_x, min_x] = missing(x)
max_x = x(:, 2);
min_x = x(:, 3);
for jj = 1:length(max_x)
for kk = 1:length(min_x)
if isnan (max_x(jj))
max_x (jj) = ((max_x(jj-1)+max_x(jj+1))/2);
elseif isnan (min_x(kk))
min_x (kk) = ((min_x(kk-1)+min_x(kk+1))/2);
elseif isnan (max_x(jj)>1)
max_x = fillmissing (max_x,'nearest');
end
end
end
This fills in the single NAN's. How do I fill in the other missing consecutive NAN's?
Aucun commentaire:
Enregistrer un commentaire