How to create multidimensional matrix from X and Y coordinates?

Hello Matlab community.
I have 24 meteorological stations which records air temperature. I would like to create a multidimensional matrix taking into accound the geographic coordinates of the meteorological stations for the distribution of 5 yearly mean temperature values. The distribution of the matrix woul be: 4 rows by 6 columns by 5; the last term represents 5 yearly mean temperature values. The values are attached to the present message:
LATITUDE LONGITUDE YEAR 1 YEAR 2 YEAR 3 YEAR 4 YEAR 5
18.0517 -92.3285 23 37 35 22 24
18.0495 -92.2141 24.3 21 32 12 42
18.0473 -92.0996 23 35 12 21 21.2
18.0449 -91.9852 32 32 10 46 21
18.0424 -91.8707 21 25 19.3 43 23
18.0399 -91.7563 34 26 9 21 21
18.1606 -92.3263 32 29 23 10 34
18.1584 -92.2117 12 31 45 18 21
18.1561 -92.0972 23 40.2 32 12 10
18.1537 -91.9826 24 45 34 21 32
18.1512 -91.8681 25.3 31 23 12 45
18.1487 -91.7536 34 25.3 21 13 21
18.2694 -92.3240 33 12 21 2 12.2
18.2672 -92.2094 21 2 12 2 12
18.2649 -92.0947 34 12 21 34 4
18.2626 -91.9801 45 2 23 45 5
18.2601 -91.8654 5 34 10 32 45.4
18.2575 -91.7508 10 2 24 32 23
18.3783 -92.3217 2 12 33 23 21.5
18.3761 -92.2070 2 23 33 15 4
18.3738 -92.0923 32 22 44 19 32
18.3714 -91.9775 12 21 54 43 24
18.3690 -91.8628 12 56 55 21 25.5
18.3664 -91.7481 12 54 45 16 37
For me is really important to find the solution to this issue, due to I have larger sets of differents meteorological data.
I really appreciate your support.
Best,
Miguel

 Accepted Answer

Let data be your 24X7 matrix. You can get what you want using reshape .
lon = reshape(data(:,2),4,6) ;
lat = reshape(data(:,1),4,6) ;
%
T = zeros(4,6,5) ;
for i = 1:5
T(:,:,i) = reshape(data(:,i+2),4,6) ;
end

More Answers (1)

T = readtable('temperature_values_.xls');
data = T{:,:};
out = permute(reshape(data',size(data,2),4,[]),[2, 3, 1]);
other variant with use scatteredInterpolant:
temperature = ...
arrayfun(@(ii)scatteredInterpolant(data(:,2:-1:1),data(:,ii)),(3:7)','un',0);
use
>> N_of_station = 7;
year1 = 3;
temperature{year1}(temperature{1}.Points(N_of_station,:))
ans =
23
>>

Categories

Find more on Weather and Atmospheric Science in Help Center and File Exchange

Products

Asked:

on 5 Oct 2017

Edited:

on 5 Oct 2017

Community Treasure Hunt

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

Start Hunting!