Transform 2d array latitude into 1d array latitude

5 次查看(过去 30 天)
Hi, i have downlod the climate projection of sea surface temeperature obtained with the cmip6 model.
My problem is that i have a 2d array for latitude and longitude and my sst is a 3d array sst(tos, i , j) where
the combination of i,j corrisponds to a value for latitude and longitude, i would like to have sst as sst(tos, lon,lat) in order to have
easy way to plot it and confront it with other results. Do you have any advice .
What I want to do is something like : countourf( latitude(i,j) , longitude(i,j) , tos ).
it is not working becasue i and j are vectori and not single values i think.
Thanks
Mike

回答(2 个)

Tevel Hedi
Tevel Hedi 2022-5-1
search "transpose" in matlab and use that command on your vectors.
  1 个评论
MICHELE GNESOTTO
MICHELE GNESOTTO 2022-5-1
it's not working, i want to go from a matrix to vactors , transpose is not recucing the dimension though.

请先登录,再进行评论。


Keegan Carvalho
Keegan Carvalho 2022-5-1
编辑:Keegan Carvalho 2022-5-1
Is "tos" the SST variable? I don't see "sst" it in the figure.
If "tos" is the SST variable, then 256 x 220 x 1032 would correspond to lon x lat x time OR lat x lon x time; where "time" would be the SST values for the given "time" (eg. daily/monthly values)
If it is the first instance, then
newsst = permute(tos, [3 1 2]);
% This would make it time x lon x lat
If it the second instance, then
newsst2 = permute(tos, [3 2 1]);
% This would make it time x lat x lon
  2 个评论
MICHELE GNESOTTO
MICHELE GNESOTTO 2022-5-1
yes tos is sst variable, sorry for bad explanation. My problem is that latitude is 256x220 and not something like 256x1, so for example when i try to plot with countourf and add the coaslines i have problem to match the graphics since i don't know how how to handle the fact that tos depends on i and j and not on latitude and longitude , where i and j corrisponds to the couple of the matrix of latitude and longitude , that is latitude is i x j and same longitude
M_D8993
M_D8993 2022-5-29
Hello! Was wondering whether you found the answer to this? I am also experiencing the same issue of thrying to get latitude and longitude into a vector (i.e. moving from a 2D array to 1D) so I can extract data for a geographical area. I think my indexing is not working because latitude and longitude are 2D.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Geographic Plots 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by