Create arrays of observations
Afficher commentaires plus anciens
Hello everybody,
Probably it is a very silly question but I am struggling on it..
I have a series of observations saved as 'pt_mean_lev1_1' up to 'pt_mean_lev1_348' (see picture below) and I want to make an array of them being a = 1x348. How can I do that?
Thank you very much!

3 commentaires
Rik
le 4 Août 2021
How did those variables get in your workspace? That is the place to address this. There are fixes for once you are in this mess, but it is easier to address this at the source.
CARLOTTA DENTICO
le 4 Août 2021
CARLOTTA DENTICO
le 4 Août 2021
Réponse acceptée
Plus de réponses (2)
CARLOTTA DENTICO
le 4 Août 2021
0 votes
1 commentaire
Sulaymon Eshkabilov
le 4 Août 2021
I meant a separate thread and not here. Two questions in one thread that is confusing.
Rik
le 4 Août 2021
You should not name your variables dynamically. Why are you not storing them in an array when reading? What is wrong with the code below?
lon = ncread('topaz_V4_myocean_arctic_grid1to8_da_class1_19910115.nc', 'longitude');
lat = ncread('topaz_V4_myocean_arctic_grid1to8_da_class1_19910115.nc', 'latitude');
fram = (lon>=0 & lon<=20 & lat>=76 & lat<=80);
pt_lev1_=zeros(size(pt_lev1,1)*size(pt_lev1,2),348);
for k = 1:348
pt_lev1_(:,k) = reshape(pt_lev1(:,:,k),[],1);
end
pt_mean_lev1_=mean(pt_lev1_(fram,1:k),1,'omitnan')
Catégories
En savoir plus sur NetCDF dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!