MATLAB Answers

interpolating longitudes from latitude

2 views (last 30 days)
Gillian Goldhagen
Gillian Goldhagen on 16 Jun 2020
Answered: Sujay C Sharma on 17 Jun 2020
I have a bunch of lattitudes and longitudes that make up a specific shape with some latitudes and longitudes being repeated.
I need to find a way to interpolate what latitudes would be at a given lattitude point from 40.5-43.5 every .1 interval. My actual data is much more specific with few lattitude points actually at simple numbers and most looking like this: 43.2930.
Is it possible to get this information from my dataset of 536x2 lat and long?
I have tried sorting my data: sorteddata=sortrows(data,[1,2]);
to be able to use: newlon=intrplon(sorteddata(:,1), sorteddata(:,2), 40.5)
but it won't go through I assume since I have multiples of both lat and long.
It keeps giving me this error: Error using intrplon (line 61)
LATITUDE must be monotonic.
Any advice would be great, thank you.

  0 Comments

Sign in to comment.

Answers (1)

Sujay C Sharma
Sujay C Sharma on 17 Jun 2020
Hi,
The polyfit and polyval functions may be able to help you out in this regard. Here is an example of how you can use it for interpolation:
X = [1:10];
Y = [1:10];
c = polyfit(X,Y,1);
Input = [10:0.1:11];
Output = polyval(c,Input);
disp(Output);
Your latitudes and longitudes from your dataset can be used in place of X and Y and your Input would be [40.5:0.1:43.5] in your case. Do take a look at the documentation of polyfit and polyval for more examples

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!