Creating a Grid of Lat/Lon Values, in two columns

조회 수: 11 (최근 30일)
Greg B.
Greg B. 2015년 8월 5일
댓글: Kelly Kearney 2015년 8월 5일
Howdy.
The first thing I'm trying to do is take a vector lat = [-14:0.5:14] and a vector lon = [-14:0.5:14], and make a 3249X2 matrix such that I have:
-14 -14
-14 -13.5
-14 -13.0
.
.
.
14 13.0
14 13.5
14 14
So I should have 3249 rows and 2 columns, where each latitude value matches with a respective longitude value. I have tried using repmat, but that didn't quite work. Does anyone have any ideas on how to do this?
Thanks for your help.
  댓글 수: 2
Greg B.
Greg B. 2015년 8월 5일
Thank you Kelly. What I did was this:
lat = flipud(load('Grid')) %LATITUDE
lon = load('Grid')
[LAT LON] = meshgrid(lat,lon);
Where LAT and LON are both 51X51 matrices, except LAT is flipped. I wish to now just plot points, such that cell (1,1) of lat plots with cell (1,1) of LON, and so on. Do you have an idea about where to start?
Thank you.
Kelly Kearney
Kelly Kearney 2015년 8월 5일
Please add your responses to the relevant answer; it makes threads much easier to follow. I've duplicated this and will respond in my answer below.

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

채택된 답변

Kelly Kearney
Kelly Kearney 2015년 8월 5일
You'll want to use meshgrid or ndgrid to expand the vectors:
[lat, lon] = meshgrid(-14:0.5:14);
ltln = [lat(:) lon(:)]
  댓글 수: 1
Kelly Kearney
Kelly Kearney 2015년 8월 5일
Greg commented:
Thank you Kelly. What I did was this:
lat = flipud(load('Grid')) %LATITUDE
lon = load('Grid')
[LAT LON] = meshgrid(lat,lon);
Where LAT and LON are both 51X51 matrices, except LAT is flipped. I wish to now just plot points, such that cell (1,1) of lat plots with cell (1,1) of LON, and so on. Do you have an idea about where to start?
Thank you.
----------------
The flip seems a bit unnecessary; if you're pairing every longitude with every latitude, the order is somewhat irrelevant. But it doesn't hurt, I guess.
I suggest you read through the "Getting Started" portion of the documentation to familiarize yourself with various plotting techniques. If you simply want to plot a dot at each grid point:
plot(LAT, LON, 'k.');
Though I'm guessing you probably want to plot some data values at each point, so perhaps you should investigate surf, mesh, pcolor, contour, etc.

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by