Interpolation(?) of 3D array
1 回表示 (過去 30 日間)
古いコメントを表示
I have a 3D array (vardata) which contains sound pressure level data at a series of lat/lon coordinates for 91 different frequencies.
The vardata variable is available here: https://drive.google.com/file/d/1wnIFacUnRgkvSHy0MARsRUe1UBUxVsEr/view?usp=sharing
For each frequency, I would like to extract sound pressure level data at particular coordinates of interest (x2 and y2, attached).
vardata=ncread('TL__Map1_15C_sand1__20mres_-36.265137N_174.790466','TLdata'); %3D array (freq(91)xlongitude(489)xlatitude(280)
ncdisp('TL__Map1_15C_sand1__20mres_-36.265137N_174.790466')
H_latdata=ncread('TL__Map1_15C_sand1__20mres_-36.265137N_174.790466','H_latdata');
H_londata=ncread('TL__Map1_15C_sand1__20mres_-36.265137N_174.790466','H_londata');
H_freqdata=ncread('TL__Map1_15C_sand1__20mres_-36.265137N_174.790466','H_freqdata');
% Plot data for single frequency
for i = 30 %for one frequency
pcolor(H_londata,H_latdata,squeeze(vardata(i,:,:))') ;
shading interp
drawnow
end
colorbar
caxis([0 100])
xlabel('Longitude');
ylabel('Latitude');
ylabel(colorbar,'Sound Pressure Level','FontSize',12,'rotation', 270, 'VerticalAlignment', 'bottom')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/817659/image.png)
The coordinates of interest are x2 and y2. Plotted here:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/817664/image.png)
For each frequency, I would like to store the data at these coordinates of interest.
I considered griddedInterpolant:
freq30=squeeze(vardata(30,:,:)); %extract data for one frequency
F=griddedInterpolant(freq30);
but I am unsure how to then extract the data at the coordinates of interest.
Zooming in on the above figure (without 'shading interpolation'), you can see that the points fall on top of a grid, so I guess the best solution is to take the value of the cell that each point falls within, but I'm not sure how to do that.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/817729/image.png)
0 件のコメント
回答 (1 件)
Cris LaPierre
2021 年 12 月 28 日
Using your code above, the calculation would be
[Lon,Lat] = meshgrid(H_londata,H_latdata);
SP_coi = interp2(Lon,Lat,squeeze(vardata(i,:,:))',x2,y2);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!