Linear Inperpolation for missing values

조회 수: 2 (최근 30일)
Damith
Damith 2015년 2월 12일
댓글: Star Strider 2015년 2월 12일
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

채택된 답변

Star Strider
Star Strider 2015년 2월 12일
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
Damith
Damith 2015년 2월 12일
Thanks so much. I appreciate your quick response.
Star Strider
Star Strider 2015년 2월 12일
My pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by