making a area plot with lat,lon and a variable corresponding to that location

I have latitude, longitude and temperature corresponding to those locations. How can I make a color plot in a way it show how temperature varies along that region? When I bring the cursor to the location I am interested at, if I can read the temperature, that would be much helpful as well.
Thanks, Thishan

Answers (2)

You need to read about pcolor , surf .
[X,Y,Z] = peaks(50) ;
figure(1)
surf(X,Y,Z)
figure(2)
pcolor(X,Y,Z)
If lon, lat are your spatial coordinates and T is your mxn temeprature matrix:
surf(lon,lat,T) ; % if throws error, use T'

7 Comments

Thanks. But when using surf(lon,lat,T) or surf(lon,lat,T') it gives an error saying T has to be a matrix. T is a column similar to lon and lat.
Ohk...then your T is not a matrix? What are dimensions of lon, lat and T? Attach one file, you zip it and attach.
here is the attachment. If you could tell me a way to get the lat,lon,T values based on the movement of the cursor, that would help me as well.
What you have in the file is 1D data, how you expect area plot?
Using
p1.lat = ncread('sbssondewnpnM1.b1.20110421.135800.cdf', 'lat');
p1.lon = ncread('sbssondewnpnM1.b1.20110421.135800.cdf', 'lon');
p1.tdry = ncread('sbssondewnpnM1.b1.20110421.135800.cdf', 'tdry');
scatter3(p1.lat, p1.lon, p1.tdry)
then we can see the result is effectively a 3D line with 2066 points. The other file is similar but with 2491 points.
There is no obvious way to turn that data into areas.
Thank you very much, Walter. This is much better. What this data represents is, how the temperature varies with longitude and latitude as measured by a balloon ("sounding" in meteorology).
Also, it would be great if I can modify this code to a loop to read all the files. It is easy to create a loop if we are considering (sbssondewnpnM1.b1.20110421.135800.cdf and sbssondewnpnM1.b1.20110421.205600.cdf),only the first 6 numbers stands for the year,month,date. Most of the files have 2 files for the same day similar to this case. For the pressure (here it appears as "pres") there are common values for all files; 850, 700. For each day, I want to get the average of "tdry" for 700 pressure level and 850 pressure level separately (sometimes there might no data for 850 pressure level). Please not that two digits after the "dot" for day is different(because they sent at different times). I am attaching another two files for clarity.
Thank you very much, Thishan
Chances are that dir() will return the file names in order by encoded date; you could sort() the names to be certain. It looks to me as if you would not need to use something like natsortfiles() from the File Exchange as you have a fixed number of digits for each field, and the date fields are arranged in a useful order already.

Sign in to comment.

You will probably need to use either griddedInterpolant or scatteredInterpolant; then you would call the resulting function with an array of locations and plot the result.

Categories

Tags

Community Treasure Hunt

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

Start Hunting!