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: trouble saving data structure to a file
Replies: 7   Last Post: Nov 12, 2012 10:21 AM

Advanced Search

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

Posts: 25
Registered: 3/17/11
Re: trouble saving data structure to a file
Posted: Nov 6, 2012 9:20 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Steven_Lord" <slord@mathworks.com> wrote in message <k7a66a$asf$1@newscl01ah.mathworks.com>...
>
>
> "Ben Ruppel" <brspam@cox.net> wrote in message
> news:k79i7r$76h$1@newscl01ah.mathworks.com...

> > Hello,
> > The save command is driving me crazy. I am working in a GUI where I am
> > storing some data variables in the handles data structure. I have
> > collected the data I wish to export into a structure called
> > handles.inputData. handles.inputData contains three structures, which are
> > called A, B, C. Each of these contains several other structures and
> > arrays.
> > I want to export A, B, and C to a file, but I keep getting "The argument
> > to -STRUCT must be the name of a scalar structure variable."
> >
> > I have a variable called "filename" which contains a path and name of an
> > output file.
> >
> > The command: save(filename, '-struct', 'handles.inputData.A') does not
> > work.

>
> handles.inputData.A is not the name of a scalar structure variable. It is an
> expression that when evaluated returns a scalar struct array. Those are two
> different things.
>

> > The command: save(filename, '-struct', 'handles.inputData') does not
> > work.

>
> Ditto.
>

> > The command: save(filename, '-struct', 'handles') does work.
>
> handles IS the name of a scalar struct array and so is acceptable for use
> with the -struct flag.
>

> > handles.inputData is confirmed to be a "1x1 struct" in the Variable Editor
> > window.
> >
> > Can anyone help me understand what is going wrong here and show me how to
> > save my structures?

>
> D = handles.inputData;
> save(filename, '-struct', 'D')
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com


Hello Steve,

Thank you very much, your solution worked. I'm not thrilled with creating a copy of A, B, and C since these are very large variables.

How can you tell that handles.inputData is not a scalar struct variable? In Variable Editor both handles and handles.inputData are listed as "1x1 struct". Furthermore, they are both data "things" in matlab which contain multiple data structures and arrays and cell arrays. What makes the one different from the other?

Is there a way for me to make handles.inputData a scalar struct variable?

Or is the problem more that handles.inputData is an expression? If that is the case, is there a way to point to this data structure that does not count as an expression?

Thank you,
Ben



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.