How do I make my meshgrid plot on a figure instead of just vertical lines?

4 views (last 30 days)
Hi all, I'm trying to create a series of meshgrids in longitude and latitude at different grid intervals to put over a basemap for cross-comparison between grid sizes. I don't have any issues creating the meshgrids or viewing the subsequent matrices in my workspace, but when I plot them I can only see the vertical (longitudinal) lines of the grid, not both those and the horizontal (latitude) ones. Does anyone know how to change my code to make it so that I can see the grids as they are supposed to render? I've put the code for one of the meshgrids and its associated plot below. Any help would be much appreciated, thank you!
[xgrid1,ygrid1] = meshgrid(-92:0.1:-84,36:0.1:43);
figure
plot(US(:,2),US(:,1));
xlabel('Longitude');
ylabel('Latitude');
title('USHCN Station Distribution');
daspect([1 1 1]);
xlim([-92 -84])
ylim([36 43])
hold on
plot(ILINStations(:,2),ILINStations(:,1), '.');
plot(xgrid1,ygrid1,'k-');

Accepted Answer

Ian Gordon
Ian Gordon on 28 Oct 2021
Sorry, just realized my mistake! For any future visitors to this question, I had forgotten to add a line at the end of the plotting script that was essential. Please see the adjusted code below, specifically the last line:
[xgrid1,ygrid1] = meshgrid(-92:0.1:-84,36:0.1:43);
figure
plot(US(:,2),US(:,1));
xlabel('Longitude');
ylabel('Latitude');
title('USHCN Station Distribution');
daspect([1 1 1]);
xlim([-92 -84])
ylim([36 43])
hold on
plot(ILINStations(:,2),ILINStations(:,1), '.');
plot(xgrid1,ygrid1,'k-');
plot(xgrid1',ygrid','k-');

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!