Linear Inperpolation for missing values

2 vues (au cours des 30 derniers jours)
Damith
Damith le 12 Fév 2015
Commenté : Star Strider le 12 Fév 2015
Hi,
I need to find the missing values for Lat, Long in column 5 and 6 using linear interpolation. Can anybody suggest me a method in MATLAB? Excel worksheet is attached here.
Thanks in advance.
Year Month Day Time Lat Long
1998 1 16 0 -12 42.7
1998 1 16 3
1998 1 16 6 -12.2 42.4
1998 1 16 9
1998 1 16 12 -13 42.1
1998 1 16 15
1998 1 16 18 -13.8 41.9
1998 1 16 21
1998 1 17 0 -14.6 41.5
1998 1 17 3
1998 1 17 6 -15.4 40.4
1998 1 17 9
1998 1 17 12 -15.9 38.9
1998 1 17 15
1998 1 17 18 -16.1 38
1998 1 17 21
1998 1 18 0 -16.8 37.4
1998 1 18 3
1998 1 18 6 -17.1 36.2
1998 1 18 9
1998 1 18 12 -17.4 35.3
1998 1 18 15
1998 1 18 18 -18.1 35.6
1998 1 18 21
1998 1 19 0 -18.8 35.7
1998 1 19 3
1998 1 19 6 -19.3 34.8
1998 1 19 9
1998 1 19 12 -19.8 34.5
1998 1 19 15
1998 1 19 18 -20.2 34.5
1998 1 19 21
1998 1 20 0 -21.2 34.7
1998 1 20 3
1998 1 20 6 -22.1 34.9
1998 1 20 9
1998 1 20 12 -22.5 35.3
1998 1 20 15
1998 1 20 18 -23 36.1
1998 1 20 21
1998 1 21 0 -23.4 36.5
1998 1 21 3
1998 1 21 6 -23.9 37.2
1998 1 21 9
1998 1 21 12 -24.6 38.5
1998 1 21 15
1998 1 21 18 -25.2 39.9
1998 1 21 21
1998 1 22 0 -25.4 41.4
1998 1 22 3
1998 1 22 6 -25.6 42.9
1998 1 22 9
1998 1 22 12 -25.8 44.3
1998 1 22 15
1998 1 22 18 -25.8 45
1998 1 22 21
1998 1 23 0 -25.7 45.5
1998 1 23 3
1998 1 23 6 -25.6 46.3

Réponse acceptée

Star Strider
Star Strider le 12 Fév 2015
Use the interp1 function:
[d, s, r] = xlsread('Lat_Long_Linear_Interpolation.xls');
dn = datenum([d(:,1:4) repmat([0 0],size(d,1),1)]); % Convert Dates To Serial
nonan = ~isnan(d(:,5)); % Use Valid Data For Interpolation
latlon = interp1(dn(nonan),d(nonan,5:6), dn); % Interpolate (Linear)
d_intrp = [d(:,1:4) latlon]; % Reconstruct Full Data Matrix
  2 commentaires
Damith
Damith le 12 Fév 2015
Thanks so much. I appreciate your quick response.
Star Strider
Star Strider le 12 Fév 2015
My pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Interpolation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by