MATLAB Answers


How to import 3GB netcdf file into matlab

Asked by Shakir Hussain on 9 Jan 2019
Latest activity Commented on by Shakir Hussain on 12 Jan 2019
Accepted Answer by KSSV
I know, how to read netcdf data into matlab and due to the size of this file (3gb) maltab is saying out of limit (array exceeds maximum array size preference. Creation of arraysgreater than this limit may take a long time and cause MATLAB to become unresponsive.)
I wan to read variables sparately and I did some to them by using simple ncread but the size of main variable is about 3gb and that evil is making problem here.
How Could I deal it ?
thank you in advance


Sign in to comment.




1 Answer

Answer by KSSV
on 9 Jan 2019
Edited by KSSV
on 9 Jan 2019
 Accepted Answer

YOu are trying to load the enitre data from netCDF into MATLAB..this is not the right option..first get familiar with the data..if the data is 3D, you can read matrix one by one in a loop and process or plot. If your matrix is of long dimension and only one can read chunk or part of it by providing indices. Read about ncread, you have maultiple options out there.


on 10 Jan 2019
We have a plot it means..we have the data in hand....I am reading a specific time stamps matrix and plotting it. If you want to save it..then again you will get out of memory problem if you save entire matrix with same resolution. If you down scale, if the matrix is not huge..then you can have it as a 3D matrix. But the question again is do I need a 3D matrix in workspace? What for?
Off course, we need 3d matrix (i.e. lat*lon*precip) but I was asking about the possibility to get output and save in 5-10 small parts.
e.g 10902x6818x846 split into
10902x6818x100...... and so on and save each file separately but this execution must be carry put in sequence
How could we can regrid it directly from nc file and take result of regrid as output?

Sign in to comment.