Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: problem using netcdf toolbox's "ncsave" with matlab2012
Replies: 1   Last Post: Jan 22, 2013 1:35 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
rachael

Posts: 16
Registered: 2/10/09
problem using netcdf toolbox's "ncsave" with matlab2012
Posted: Jan 21, 2013 1:58 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Has anyone else run into trouble using netcdf library tools like "ncsave" in the 2012b version of matlab (iOSX Mtn. Lion)?

I understand that the 2012b version of matlab has a built-in library of netcdf tools
(http://www.mathworks.com/help/matlab/ref/netcdf.html)--which is great(!)--but I would like to still be able to use "ncsave" for backward compatibility in using code that I created with earlier matlab releases. The problem that I'm running into is that ncsave not only doesn't work but completely overwrites the netcdf file that I'm trying to save to so that the file is not longer recognized as a netcdf and is only KBs in size.

Here is exactly what I did:

1) Copied existing netcdf to new file, "newfile". File size same as orig. (64.9 MB)
2) Read/write netcdf variable "var" to "newfile":

Specific matlab calls and error below
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> ncload('newfile.nc', 'var');
>> ncsave('newfile.nc', 'var');

Overwriting newfile.nc
Undefined variable variables.

Error in ncsave (line 10)
myvars =evalin('caller',' whos(variables{:}) ');

10 myvars =evalin('caller',' whos(variables{:}) ');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"newfile" size is now 32 bytes

I really liked using ncload and ncsave because it allowed me to load and save multiple variables at once. The new built-ins don't seem to have this functionality.

Does anyone know of a fix for using "ncsave" in 2012b?

Alternatively, I'd settle for a way to either import/export mult. variables using the built-in functions, but I'd rather not have to re-write the functions that use "ncsave".



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.