Is there a problem with adjusting the code for plotting climate data in Matlab?

In summary: If it's the latter then I think you'll need to get the data covering the entire surface, or find a way to generate it that way.
  • #1
Arjani
21
1
I have climate data that I am plotting in Matlab with a script. The relevant code for this problem, I think, is this:

Code:
lon = reshape(grid_txt_lon,144,73);
lon(lon>180) = lon(lon>180) - 360;
lon = [lon(74:144,:);lon(1:73,:)];
lat = reshape(grid_txt_lat,144,73);
deg = reshape(degree,144,73);
deg = [deg(74:144,:);deg(1:73,:)];

The map is divided in a grid of 2.5 degrees each, so the 144 longitude comes out to 360 degrees and the 73 latitude comes out to 182.5 degrees. I guess the latitude has one degree overlap. Using these values, I get a plot such as this:

http://img36.imageshack.us/img36/479/ex1pr.jpg

But this isn't what I need, what I need is to plot a band of ±40 degrees (using different data) around the equator. So, I adjust the code to these values:

Code:
lon = reshape(grid_txt_lon,144,[B][U]33[/U][/B]);
lon(lon>180) = lon(lon>180) - 360;
lon = [lon([B][U]34[/U][/B]:144,:);lon(1:[B][U]33[/U][/B],:)];
lat = reshape(grid_txt_lat,144,[B][U]33[/U][/B]);
deg = reshape(degree,144,[B][U]33[/U][/B]);
deg = [deg([B][U]34[/U][/B]:144,:);deg(1:[B][U]33[/U][/B],:)];

Changes emphasized. It works somewhat, but the graph becomes screwed up:

http://img803.imageshack.us/img803/6199/ex2u.jpg

Exactly at 2*40, or 80 degrees, it starts doing weird things. Is there a problem in the way I adjusted the code perhaps?
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
I played around with it some more and adjusted the adjusted code in the following way, changes emphasized again:

Code:
lon = reshape(grid_txt_lon,144,33);
lon(lon>180) = lon(lon>180) - 360;
lon = [lon([B][U]74[/U][/B]:144,:);lon(1:[B][U]73[/U][/B],:)];
lat = reshape(grid_txt_lat,144,33);
deg = reshape(degree,144,33);
deg = [deg(34:144,:);deg(1:33,:)];

This results in the following graph, which looks more like what you'd expect:

http://img687.imageshack.us/img687/3705/ex3w.jpg

But how can I be sure this still reflecs reality and doesn't just look correct due to my tweaks to the code??
 
Last edited by a moderator:
  • #3
I have one thing I'm not sure of,

Is the data covering the entire surface, and do you want it to be cropped for the purposes of an image, or does the data only cover your equatorial band of interest, and are you trying to make sure it is overlaid onto the world map with the correct scaling?

If it's the former then I think this can be solved at the plotting level, depending on what code you're using, eg. by adjusting the pcolor face alpha values depending on the region you want to be omitted from the image. But the specifics will depend on the plotting code.
 

What is the problem with my graph in Matlab?

The most common problem with graphs in Matlab is incorrect data labeling or plotting. Make sure that your data is correctly labeled and that you are using the correct plot function for your data.

Why is my graph not showing up in Matlab?

There are a few possible reasons for this issue. First, make sure that you have correctly specified the plot function and that you have included all necessary arguments. Additionally, check that your data is correctly formatted and that there are no errors in your code.

How can I change the appearance of my graph in Matlab?

To change the appearance of your graph, you can use various plot formatting functions in Matlab. These include functions for changing the color, line style, and marker style of your graph, as well as functions for adding labels, titles, and a legend.

What can I do if my graph looks distorted or incorrect in Matlab?

If your graph appears distorted or incorrect, check that your data is correctly formatted and that you are using the correct plot function. You can also try adjusting the axis limits or using different scaling options in Matlab to improve the appearance of your graph.

How can I save my graph as an image file in Matlab?

To save your graph as an image file, you can use the "saveas" function in Matlab. This function allows you to specify the file format and location for your graph image. Alternatively, you can use the "print" function to save your graph as a PDF or other file format.

Back
Top