Thread Subject: save command can not save variable name?

Subject: save command can not save variable name?

From: zhengquan

Date: 26 Jan, 2008 02:30:29

Message: 1 of 3

Hello,
I used

save -ASCII results rc re lt rho_c_m2 rho_c_cm2
r...
pad_distance

to save the variables in to file results, but it
turned out that the numbers stored in the file
results does not have variable names before them,
it is not convenient to see which variable
corresponds to which data. I read the help but did
not find any switch to turn on this function.

Thanks for your help.

Zhengquan

Subject: save command can not save variable name?

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 26 Jan, 2008 16:09:41

Message: 2 of 3

In article <f9d690d9-b5eb-4622-bcbe-5254e145fd4f@i12g2000prf.googlegroups.com>,
zhengquan <zhang.zhengquan@gmail.com> wrote:

>I used

>save -ASCII results rc re lt rho_c_m2 rho_c_cm2
>r...
>pad_distance

>to save the variables in to file results, but it
>turned out that the numbers stored in the file
>results does not have variable names before them,
>it is not convenient to see which variable
>corresponds to which data.

Correct. If you need the variable name, you will
have to save the data yourself, by using fopen()
to open the file, then for each variable,
fprintf() to write the name of the variable and
fprintf() to write the contents of the variable.
At the end, fclose() the file.
--
   "Beware of bugs in the above code; I have only proved it correct,
   not tried it." -- Donald Knuth

Subject: save command can not save variable name?

From: zhengquan

Date: 27 Jan, 2008 01:46:31

Message: 3 of 3

On Jan 26, 10:09 am, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
> In article <f9d690d9-b5eb-4622-bcbe-5254e145f...@i12g2000prf.googlegroups.com>,
>
> zhengquan <zhang.zhengq...@gmail.com> wrote:
> >I used
> >save -ASCII results rc re lt rho_c_m2 rho_c_cm2
> >r...
> >pad_distance
> >to save the variables in to file results, but it
> >turned out that the numbers stored in the file
> >results does not have variable names before them,
> >it is not convenient to see which variable
> >corresponds to which data.
>
> Correct. If you need the variable name, you will
> have to save the data yourself, by using fopen()
> to open the file, then for each variable,
> fprintf() to write the name of the variable and
> fprintf() to write the contents of the variable.
> At the end, fclose() the file.
> --
> "Beware of bugs in the above code; I have only proved it correct,
> not tried it." -- Donald Knuth

Thanks.

Zhengquan

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com