<p>These days I use: <a href="https://code.google.com/p/nctoolbox/wiki/ncgeodataset">ncgeodataset</a>. The routine allows for the extraction of a subset of data without having to load the entire file or even an array into Matlab. It is great for large datasets.</p>

CC BY-SA 3.0
2015-07-26T13:48:31.413Z
2015-07-26T13:48:31.413Z
arkaia
<p>I have downloaded the sea surface temperature data from the Ocean Color website, the file is in NetCDF format and contains no of geophysical_data variables like <code>sst</code>, <code>qual_sst</code>, <code>flag_sst</code>, <code>bias_sst</code>, etc.
I used the following MATLAB code for file read and it is giving me an error: </p>

<pre><code>temp=ncread('A2014213085500.L2_LAC_SST.x.nc','sst') 
</code></pre>

<p>Error:</p>

<pre><code>Error using internal.matlab.imagesci.nc/getGroupAndVarid (line 2075)
Could not find variable or group 'sst' in file.

Error in internal.matlab.imagesci.nc/read (line 593)
        [gid, varid] = getGroupAndVarid(this, location);

Error in ncread (line 58)
vardata = ncObj.read(varName, varargin{:});
</code></pre>

<p>Can someone tell me what is the cause of the error?</p>

CC BY-SA 3.0
2015-07-27T10:54:21.623Z
There is NetCDF-3 and NetCDF-4.  What format is your data in and what format is your reading routine for?
gerrit
CC BY-SA 3.0
2015-07-27T17:04:21.333Z
What is the main difference b/w these two ? because i don't know in which format my file is, how can i find that ? i checked the file property and its just show me .NC file type.
Ahsan
CC BY-SA 3.0
2015-07-28T13:55:46.877Z
Several questions: Why that website for sea surface temperature? (Why not hycom.org?) What website? (It's always good to say exactly where.) What file did you download? Did you use ncdump to examine the contents of that file? Why did you use FTP when you could be using openDAP?
David Hammen
<oceanography><matlab><netcdf>
How to read a NetCDF4 file in Matlab?
Ahsan
# How to read a NetCDF4 file in Matlab?

(Asked by: username_0 on 2015-07-26)

I have downloaded the sea surface temperature data from the Ocean Color website, the file is in NetCDF format and contains no of geophysical\_data variables like `sst`, `qual_sst`, `flag_sst`, `bias_sst`, etc.
I used the following MATLAB code for file read and it is giving me an error:

```
temp=ncread('A2014213085500.L2_LAC_SST.x.nc','sst') 

```

Error:

```
Error using internal.matlab.imagesci.nc/getGroupAndVarid (line 2075)
Could not find variable or group 'sst' in file.

Error in internal.matlab.imagesci.nc/read (line 593)
        [gid, varid] = getGroupAndVarid(this, location);

Error in ncread (line 58)
vardata = ncObj.read(varName, varargin{:});

```

Can someone tell me what is the cause of the error?

**Tags:** oceanography, matlab, netcdf

> **Comments:**
> **username_1**: There is NetCDF-3 and NetCDF-4.  What format is your data in and what format is your reading routine for?  
> **username_0**: What is the main difference b/w these two ? because i don't know in which format my file is, how can i find that ? i checked the file property and its just show me .NC file type.  
> **username_2**: Several questions: Why that website for sea surface temperature? (Why not hycom.org?) What website? (It's always good to say exactly where.) What file did you download? Did you use ncdump to examine the contents of that file? Why did you use FTP when you could be using openDAP?  

---

## 1 answers

### Answer by username_3 on 2015-07-26. Score: 6 | Accepted answer

These days I use: [ncgeodataset](https://code.google.com/p/nctoolbox/wiki/ncgeodataset). The routine allows for the extraction of a subset of data without having to load the entire file or even an array into Matlab. It is great for large datasets.


---

