View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
NetCDF reader

4.6 | 23 ratings Rate this file 45 Downloads (last 30 days) File Size: 2.65 KB File ID: #15177 Version: 1.0

NetCDF reader


Paul Spencer (view profile)


02 Jun 2007 (Updated )

Reads NetCDF files into matlab structure

| Watch this File

File Information

Function to read version 1 (classic 32bit) NetCDF files into a matlab structure.


This file inspired Read Global Topographic Data.

MATLAB release MATLAB 7 (R14)
Other requirements Currently only tested under 32bit windows.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (32)
11 Sep 2016 panos raptis

nowdays there are toolboxes that make nc file very hand-able.
but if you use an older version of matlab (before 2011) this script is a very good option.

but i am using a 2009 matlab, and it keeps turning my data to int16 loosing all the info in the decimals (my scripts in newer version using ncinfo and ncread works correctly)

I have no idea how to treat this bug

Comment only
22 Mar 2015 el gherbi mohcine


Comment only
28 Aug 2013 Emmanuel Farhi

This contribution is good as it does not depend on any other library.

09 Aug 2012 kashif saleem

good job thanks

29 Feb 2012 Judyta

Judyta (view profile)

does Matlab reads also .ncs file?

Comment only
21 Jul 2011 sana hamouda

Thank you very much for this code it seems work but I can't use struct file on matlab Could you please help me to extract the variables from S

26 Apr 2011 Lisa

Lisa (view profile)

03 Feb 2011 Brian Emery

21 Jan 2011 Justin Winokur

Thanks for this. In our group, a few people have the newer 2010 version of Matlab with a built in netCDF library. This is good for one of my machines that does not have it. A few tweaks to my own codes here and there to use it but it works nicely. I am using it under SUSE.

Comment only
31 Aug 2010 Mainul

Mainul (view profile)

I tried to extract COSMIC ionPrf file runing netcdf.m . It reads only the header information (NumRecs: 0). I need to read data records. Can any one tell me how to read data?

Comment only
17 May 2010 roberto

I am using netcdf.m file with .nc format but I got this error:
Error using ==> reshape
To RESHAPE the number of elements must not change.
The outcome contains only 2 out of 3 matrix.
What should I do to resolve the error?

Comment only
31 Mar 2010 Alice

Alice (view profile)

I've downloaded netcdf.m file. In which folder I have to put it?I use Matlab 7.7 r2008b. Please help me! Thanks

Comment only
28 Feb 2010 Pavel ?

excellent work!

16 Oct 2009 Imtiaz Rangwala

visualize netcdf

Comment only
20 May 2009 Michael Kleder

Excellent submission. Note that unsigned integer variables (uint8) seem to be loaded as signed integers (int8). I use the typecast function to correct that. I haven't checked for any other bugs. Thanks for this really useful function!

26 Feb 2009 Richard Sonnenfeld

I haven't used it heavily yet so there may still be issues -- but it appears that this script works just fine for Matlab in Linux. (Ubuntu/Debian). It really ought to -- NETCDF is supposed to be platform agnostic.

22 Jan 2009 naratip santitissadeekorn

??? Error using ==> feval
Undefined function or method 'mexcdf60' for input arguments of type 'char'.

What should I do to resolve the above error?
I am totally new to this type of data and mex-files. Please, help.

Comment only
21 Oct 2008 roc light

30 Sep 2008 Jian Xu

I really need this function, I hope it's helpful..

10 Sep 2008 William Amidon

works beautifully. Thank you so much. This is a great help for us matlab users trying to work with large climate datasets.

27 Jul 2008 Niranjan kumar

I am extreamly thank you

03 Jun 2008 ramy MAROUS

17 May 2008 Usama Anber

great, but how to visualize climate data on a map ?

06 May 2008 Patrizio M


08 Apr 2008 D Luna

Great! Fantastic!

29 Jan 2008 w s

Thanks a lot. Exactly what I needed.

21 Jan 2008 ali altalhy

23 Nov 2007 Ibrahim Modibbo

Wow! I cant believe it...even people's comments until i saved this file into my working dir and used it in place of load on matlab file is there!
Thats a great job!

Will it be possible for you to extend this for ARGO data, and possibly how to make some few plots? This would have added extreme help to many people! Pls reply me....

I am PhD student at National Oceanography Centre, Southampton, UK.

Hope to hear from you!


22 Oct 2007 Liam Harrington-Missin

Very Easy to use and quick, at least for smaller NetCDF files

22 Jun 2007 Patrick Gagnon

It's by far the simplest way that I found to read netcdf data in Matlab R14.

11 Jun 2007 FAISA MOHTI


04 Jun 2007 Kelly Kearney

This is a nice complement to some of the more powerful netcdf libraries available. Becuase it reads in an entire file at once, it can only deal with small .nc files, but is much less hassle than the mexnc library I usually use. However, it would be nice if it did some checks ahead of time to see if the file it's reading is too big to be read into Matlab all at once (based on the header data), and errored out immediately, rather trying to do the impossible.

Contact us