combine Latitude and longitude country data from multiple arrays into one array
Show older comments
I have an array (MYD_countries) of size 249*64800 in which the first dimension represents different countries in the world and the second dimension represents global data grid cells of 1-degree data (180*360 = 64800). Each country data has data values within the country grid points and NaN elsewhere. I want to combine the data of all countries together and reduce its dimension to 1*64800 so that I can plot it at one call using geoshow. I have tried it using a loop as below but it is only storing the last country data, not all country data. Could anybody help please?
for i = 1:249;
for j = 1:64800;
if(MYD_countries(i, j) ~= NaN);
MYD_all_countries_plot (1, j) = MYD_countries (i, j);
else;
end;
end;
end;
Accepted Answer
More Answers (1)
KSSV
on 22 Jul 2021
Let A be your data of size 249*64800
[m,n] = size(A) ;
iwant = zeros(180,360,m) ;
for i = 1:m
iwant(:,:,i) = reshape(A(i,:),180,360) ;
end
Now iwant variable is a 3D matrix of size 180*360*249; each 2D matrix represents a country. You can plot it now.
3 Comments
Sagar Parajuli
on 22 Jul 2021
Edited: Sagar Parajuli
on 22 Jul 2021
KSSV
on 22 Jul 2021
USe the variable iwant(:,:,i) which is a 2D matrix using geoshow.
Sagar Parajuli
on 22 Jul 2021
Categories
Find more on Create Plots on Maps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!