Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
about "save"

Subject: about "save"

From: dhuan Du

Date: 21 May, 2009 21:01:02

Message: 1 of 2

I use the command "save" to save some data in cell matrics after I run my code.

The code is as below:

save Yavg_Wc.dat B; % B is a cell matrics in my code.

Now, I would like to check the data in A, then I use the command line below:

load Yavg_Wc.dat;

But I got the error like below

load Yavg_Wc.dat;
??? Error using ==> load
Number of columns on line 1 of ASCII file
N:\Personal\MATLAB\Disastercode\matlab\Yavg_Wc.dat
must be the same as previous lines.

What shall I do and how can I check the data in Yavg_Wc.dat?

Thanks,

Lili

Subject: about "save"

From: Matthew Whitaker

Date: 21 May, 2009 22:23:01

Message: 2 of 2

When you saved the matrix it saved it in MATLAB's binary format. When you try to load it it sees that the extension is not .mat and assumes it is an ASCII file.

A couple of quick fixes:
To load the matrix you saved using
save Yavg_Wc.dat B;

try:
load('Yavg_Wc.dat','-mat') %the mat switch forces it to see the file as a .mat file

In the future if you want to save the data as ASCII data then:
save('Yavg_Wc.dat','B','-ascii')
 In this case
load('Yavg_Wc.dat') will work.

There are some limitations to saving ASCII data so you should read the docs at
doc save

Hope this helps
Matt

"dhuan Du" <dupeony@gmail.com> wrote in message <gv4fee$h51$1@fred.mathworks.com>...
> I use the command "save" to save some data in cell matrics after I run my code.
>
> The code is as below:
>
> save Yavg_Wc.dat B; % B is a cell matrics in my code.
>
> Now, I would like to check the data in A, then I use the command line below:
>
> load Yavg_Wc.dat;
>
> But I got the error like below
>
> load Yavg_Wc.dat;
> ??? Error using ==> load
> Number of columns on line 1 of ASCII file
> N:\Personal\MATLAB\Disastercode\matlab\Yavg_Wc.dat
> must be the same as previous lines.
>
> What shall I do and how can I check the data in Yavg_Wc.dat?
>
> Thanks,
>
> Lili

Tags for this Thread

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.

Contact us