How to create 3D matrix from geographic coordinates?

조회 수: 7 (최근 30일)
Miguel L
Miguel L 2017년 10월 4일
댓글: Aristo Pacino 2021년 7월 25일
Hello guys!
I was trying to figure out how to find the solution for this issue, however I can't find the answer and I would like to ask for the workaround.
I have 5 daily measures of wind (zonal wind) at 2550 sampling points with known geographic coordinates. In order to perform an analysis, I need to create a 3D matrix of this dimensions: ~51 x ~50 x 5.
The spatial order of the data (wind measured in 5 days) should be according to the latitude and longitude data of the sampling points, which corresponds to ~51 rows x ~50 columns (2550 sampling points). The approximately sign at rows and columns is because I don't know the exact distributions of the grid, but I assume that would be more or less in such a way. Sorry for the above.
I attach to this message the files of latitude and longitude (lat and lon, respectively), as well as the wind data.
I really appreciate your support.
Miguel

답변 (1개)

KSSV
KSSV 2017년 10월 4일
load lon.mat ;
load lat.mat ;
load data.mat ;
plot(lon,lat,'.r')
nx = 51 ; ny = 50 ; nt = size(data,2) ;
x = linspace(min(lon),max(lon),nx) ;
y = linspace(min(lat),max(lat),ny) ;
[X,Y] = meshgrid(x,y) ;
wind = zeros(ny,nx,nt) ;
for i = 1:nt
F = scatteredInterpolant(lon,lat,data(:,i)) ;
wind(:,:,i) = F(X,Y) ;
end
  댓글 수: 3
KSSV
KSSV 2017년 10월 5일
scatteredInterpolant is introduced in 2013a. I think you are using a lower version then this. Try griddata.
load lon.mat ;
load lat.mat ;
load data.mat ;
plot(lon,lat,'.r')
nx = 51 ; ny = 50 ; nt = size(data,2) ;
x = linspace(min(lon),max(lon),nx) ;
y = linspace(min(lat),max(lat),ny) ;
[X,Y] = meshgrid(x,y) ;
wind = zeros(ny,nx,nt) ;
for i = 1:nt
wind(:,:,i) = griddata(lon,lat,data(:,i),X,Y) ;
end
Aristo Pacino
Aristo Pacino 2021년 7월 25일
Hi @KSSV, what if I want hourly average of data, what should I change within for loop? Below is my function which I want to add. hour and temp is array nx1 of same dimension
[ah,~,ch] = unique(hour,'rows');
out_hour = [ah,accumarray(ch,temp,[],@nanmean)];

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

카테고리

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