save text with user define struct

  • Follow


i had define a structure>>FREQ = struct('sym',[],'prob',[],'code',[]);
is there any save function support the above struct type? i had tried
the function 'save','fprintf'.Thanks
0
Reply kahboon (11) 4/12/2008 4:18:53 PM

kahboon@gmail.com:
<SNIP want to save his/her struct...

> i had define a structure>>FREQ = struct('sym',[],'prob',
[],'code',[]); is there any save function support the above 
struct type? i had tried the function 'save'...

well, <save> WILL work...

     FREQ=struct('sym',[],'prob',[],'code',[]);
     fnam='frq.mat'; % <- use your file name!
     save(fnam,'FREQ');
     clear FREQ;
try
     FREQ
% ??? Undefined function or variable 'FREQ'.
catch
     disp('FREQ does not exist; re-loading...');
     load(fnam);
     FREQ
end

us
0
Reply us1 (8054) 4/13/2008 3:05:03 AM


On Apr 13, 11:05 am, "us " <u...@neurol.unizh.ch> wrote:
> kahb...@gmail.com:
> <SNIP want to save his/her struct...
>
> > i had define a structure>>FREQ =3D struct('sym',[],'prob',
>
> [],'code',[]); is there any save function support the above
> struct type? i had tried the function 'save'...
>
> well, <save> WILL work...
>
>      FREQ=3Dstruct('sym',[],'prob',[],'code',[]);
>      fnam=3D'frq.mat'; % <- use your file name!
>      save(fnam,'FREQ');
>      clear FREQ;
> try
>      FREQ
> % ??? Undefined function or variable 'FREQ'.
> catch
>      disp('FREQ does not exist; re-loading...');
>      load(fnam);
>      FREQ
> end
>
> us

( try
>      FREQ
> % ??? Undefined function or variable 'FREQ'.
> catch
>      disp('FREQ does not exist; re-loading...');
>      load(fnam);
>      FREQ
> end)
do i need to include the 'try'?i'm not sure with this part of code.can
i not include this part?i try the part:FREQ=3Dstruct('sym',[],'prob',
[],'code',[]);
 
fnam=3D'frq.mat'; % <- use your file name!
 
save(fnam,'FREQ');
 
clear FREQ;
but wht i get is something like this(=01IM=0F      x=9C=E3c``8=C1=CE=C0=C0=
=06?EURO=98=89=01=02X=A1|F v=07?=0CnA
=AE=81=AC@?*?=C4=C5=95=B9=0C=0C=05E=F9I=0C=C9=F9)?=0C|P=FD=A3?=3DJ=8F=D2=A3=
=F4(=3D=D0=B4=01=03=A2~c=81=8A#=D7o0=0C=02=82=C0=1APR=01=A2=CF=02I=1F=1B=01}=
=9CP??s?u=ECA?=90=F43=12?R=EF@=C0=9D=DCH?=A0|
C=03CC=10=06"? D? )(inside the file i save).something very weird.is this
save function support support update?can i use the 'a+'?Thanks.
0
Reply kahboon (11) 4/13/2008 6:17:13 AM

In article <81a2b330-0546-483b-a3e9-4b3729459e8c@q1g2000prf.googlegroups.com>,
 <kahboon@gmail.com> wrote:

>save(fnam,'FREQ');

>clear FREQ;
>but wht i get is something like this(=01IM=0F      x=9C=E3c``8=C1=CE=C0=C0=
>=06?EURO=98=89=01=02X=A1|F v=07?=0CnA
>=AE=81=AC@?*?=C4=C5=95=B9=0C=0C=05E=F9I=0C=C9=F9)?=0C|P=FD=A3?=3DJ=8F=D2=A3=
>=F4(=3D=D0=B4=01=03=A2~c=81=8A#=D7o0=0C=02=82=C0=1APR=01=A2=CF=02I=1F=1B=01}=
>=9CP??s?u=ECA?=90=F43=12?R=EF@=C0=9D=DCH?=A0|
>C=03CC=10=06"? D? )(inside the file i save).something very weird.is this
>save function support support update?can i use the 'a+'?Thanks.

save() writes in a compressed binary format, not in a readable
format.

If you want to write out a structure in a text format that can
be read in as matlab commands, then there is no direct support for
that and you will need to write some code to do the output.

-- 
  "All is vanity."                                   -- Ecclesiastes
0
Reply roberson2 (8067) 4/13/2008 2:08:42 PM

On Apr 13, 10:08=A0pm, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
> In article <81a2b330-0546-483b-a3e9-4b3729459...@q1g2000prf.googlegroups.c=
om>,
>
> =A0<kahb...@gmail.com> wrote:
> >save(fnam,'FREQ');
> >clear FREQ;
> >but wht i get is something like this(=3D01IM=3D0F =A0 =A0 =A0x=3D9C=3DE3c=
``8=3DC1=3DCE=3DC0=3DC0=3D
> >=3D06?EURO=3D98=3D89=3D01=3D02X=3DA1|F v=3D07?=3D0CnA
> >=3DAE=3D81=3DAC@?*?=3DC4=3DC5=3D95=3DB9=3D0C=3D0C=3D05E=3DF9I=3D0C=3DC9=
=3DF9)?=3D0C|P=3DFD=3DA3?=3D3DJ=3D8F=3DD2=3DA=AD3=3D
> >=3DF4(=3D3D=3DD0=3DB4=3D01=3D03=3DA2~c=3D81=3D8A#=3DD7o0=3D0C=3D02=3D82=
=3DC0=3D1APR=3D01=3DA2=3DCF=3D02I=3D1F=3D1B=3D0=AD1}=3D
> >=3D9CP??s?u=3DECA?=3D90=3DF43=3D12?R=3DEF@=3DC0=3D9D=3DDCH?=3DA0|
> >C=3D03CC=3D10=3D06"? D? )(inside the file i save).something very weird.is=
 this
> >save function support support update?can i use the 'a+'?Thanks.
>
> save() writes in a compressed binary format, not in a readable
> format.
>
> If you want to write out a structure in a text format that can
> be read in as matlab commands, then there is no direct support for
> that and you will need to write some code to do the output.
>
> --
> =A0 "All is vanity." =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 -- Ecclesiastes

Then,can i know how to read back the contain using matlab?is there any
fuction that support this format?because i want to reuse the
contain.Thanks.
0
Reply kahboon (11) 4/14/2008 12:22:04 AM

On Apr 13, 10:08=A0pm, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
> In article <81a2b330-0546-483b-a3e9-4b3729459...@q1g2000prf.googlegroups.c=
om>,
>
> =A0<kahb...@gmail.com> wrote:
> >save(fnam,'FREQ');
> >clear FREQ;
> >but wht i get is something like this(=3D01IM=3D0F =A0 =A0 =A0x=3D9C=3DE3c=
``8=3DC1=3DCE=3DC0=3DC0=3D
> >=3D06?EURO=3D98=3D89=3D01=3D02X=3DA1|F v=3D07?=3D0CnA
> >=3DAE=3D81=3DAC@?*?=3DC4=3DC5=3D95=3DB9=3D0C=3D0C=3D05E=3DF9I=3D0C=3DC9=
=3DF9)?=3D0C|P=3DFD=3DA3?=3D3DJ=3D8F=3DD2=3DA=AD3=3D
> >=3DF4(=3D3D=3DD0=3DB4=3D01=3D03=3DA2~c=3D81=3D8A#=3DD7o0=3D0C=3D02=3D82=
=3DC0=3D1APR=3D01=3DA2=3DCF=3D02I=3D1F=3D1B=3D0=AD1}=3D
> >=3D9CP??s?u=3DECA?=3D90=3DF43=3D12?R=3DEF@=3DC0=3D9D=3DDCH?=3DA0|
> >C=3D03CC=3D10=3D06"? D? )(inside the file i save).something very weird.is=
 this
> >save function support support update?can i use the 'a+'?Thanks.
>
> save() writes in a compressed binary format, not in a readable
> format.
>
> If you want to write out a structure in a text format that can
> be read in as matlab commands, then there is no direct support for
> that and you will need to write some code to do the output.
>
> --
> =A0 "All is vanity." =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 -- Ecclesiastes

i don't want to read the contain as text.I just want to reuse the file
contain as an input variable in other function(Function in other m-
file).I use fread but i fail to do so.
0
Reply kahboon (11) 4/14/2008 12:29:57 AM

kahboon@gmail.com:
<SNIP does not read the example

> I just want to reuse the file contain as an input
> variable in other function(Function in other m-
> file).I use fread but i fail to do so...

i showed you how to do it, just look at the example - 
again...

     save(fnam,'FREQ');
     clear FREQ;
     load(fnam);
     disp(FREQ);

us

0
Reply us1 (8054) 4/14/2008 12:11:02 PM

kahboon@gmail.com writes:

> i don't want to read the contain as text.I just want to reuse the file
> contain as an input variable in other function(Function in other m-
> file).I use fread but i fail to do so.

Do you need to save it to disk at all?  If your goal is to use the data
in a different m-file, pass them as function parameters, or use global
variables.

-Peter
0
Reply boettcher (2302) 4/14/2008 1:52:07 PM

7 Replies
28 Views

(page loaded in 2.745 seconds)

Similiar Articles:













7/17/2012 1:42:42 PM


Reply: