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 Center および File ExchangeGeographic Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by