Getting data from netCDF as a list

2 views (last 30 days)
Hi, I have been working with netcdf data and when I want to get the list of one variable (air temperature in this example), it gives me a list with answer(.,.,.) first and then the numbers. I would like a list that contains only the answers so I can copy it into excel easily without having to remove the answer(...) part.
Here is my code:
ncid1 = netcdf.open('air1848.nc','NOWRITE')
ncid1 =
65536
[varname, xtype, varDimIDs, varAtts] = netcdf.inqVar(ncid1,3);
varid = netcdf.inqVarID(ncid1,varname);
air = netcdf.getVar(ncid1,varid');
air(117,46,1:366)
ans(:,:,1) =
289.8800
ans(:,:,2) =
290.2100
ans(:,:,3) =
290.2100
ans(:,:,4) =
291
ans(:,:,5) =
291.5300
ans(:,:,6) =
291.3300
ans(:,:,7) =
291.0600
ans(:,:,8) =
290.9000
ans(:,:,9) =
291.7500
ans(:,:,10) =
290.1500
ans(:,:,11) =
289.1500
ans(:,:,12) =
288.2100
ans(:,:,13) =
288.4300
ans(:,:,14) =
289.6800
ans(:,:,15) =
290.2500
ans(:,:,16) =
289.7300
etc...
As you can see, the data it gives me has that extra answer(...) in front of each data entry which forces me to delete in excel. What I want is 289.88 290.21 290.21 291 etc.
I am not very familiar with netcdf files in Matlab, so if you know how I can change the way it is giving me the data, any help would be very appreciated as this would save me hours of work collecting data!
Thank you

Accepted Answer

Walter Roberson
Walter Roberson on 25 Sep 2015
mydata = air(117,46,1:366);
mydata(:)
or
squeeze(mydata)

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!