How to extract values from a 3-d .mat file?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I loaded a netcdf file and derived a .mat file which is a 3-D matrix of lon x lat x value (360 x 40 x 111). I wanted to extract the third dimension as entire column.
lon=ncread('sstarc.nc','lon');
lat=ncread('sstarc.nc','lat');
summean=ncread('sstarc.nc','sst');
I used the above code and got the mat file. The third dimension has 111 values which I wanted to extract the "111" values for the entire 360 x 40 grid as a column (eg. time series). Attached .mat file!
Looing forward to your help. Thanks!
0 comentarios
Respuestas (1)
Cris LaPierre
el 21 de Mzo. de 2020
Your mat file contains variables. Loading the mat file loads the variables back into the workspace.
load summean.mat
If there are multiple variables stored in the mat file, you can tell it to load specific variables instead of all of them.
load summean.mat filteredA
The third dimension does not have 111 values. Instead, you have 111 matrices of dimension 360 x 40 stacked on top of each other. To extract the last one, you could do the following
vals = filteredA(:,:,111);
9 comentarios
Cris LaPierre
el 22 de Mzo. de 2020
As for taking the mean when there are NaN entries, you can use the following syntax
mean(A,'omitnan')
Keegan Carvalho
el 22 de Mzo. de 2020
Editada: Keegan Carvalho
el 22 de Mzo. de 2020
Ver también
Categorías
Más información sobre NetCDF en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!