Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: Saving

Subject: Saving

From: Francesco

Date: 23 Apr, 2008 15:45:05

Message: 1 of 3

I tried to save my output files on
the external hard drive using
 
save ('E:\filename')
 
and actually my file is saved on the E: directory,
the only problem now being that in E: it is not
stored as .mat file, but "Link to Microsoft Access Office".
I don't know what to do, could you pls give me advice?
 
Here is the step of my code where this problem occurs:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
for l=1:N
 
   filename = num2str(l,'data_%d.mat');

   save ('E:\filename')
 
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
I would like to end up on the E: directory with a set of
files:
 
data_1.mat
data_2.mat
.
.
.
data_N.mat

Many thanks,
Francesco

Subject: Re: Saving

From: David

Date: 23 Apr, 2008 16:02:45

Message: 2 of 3

"Francesco " <fsarnari@maths.leeds.ac.uk> wrote in message
<funli1$56o$1@fred.mathworks.com>...
> I tried to save my output files on
> the external hard drive using
>
> save ('E:\filename')
>
> and actually my file is saved on the E: directory,
> the only problem now being that in E: it is not
> stored as .mat file, but "Link to Microsoft Access
Office".
> I don't know what to do, could you pls give me advice?
>
> Here is the step of my code where this problem occurs:
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> for l=1:N
>
> filename = num2str(l,'data_%d.mat');
>
> save ('E:\filename')
>
> end

the save should be:

save(['E:\' filename]);

or you could do:

filename = num2str(l,'E:\data_%d.mat');
save (filename)


you are not substituting the variable 'filename' you are
saving to the file named 'filename'.

Subject: Re: Saving

From: Steven Lord

Date: 23 Apr, 2008 16:52:56

Message: 3 of 3


"Francesco " <fsarnari@maths.leeds.ac.uk> wrote in message
news:funli1$56o$1@fred.mathworks.com...
>I tried to save my output files on
> the external hard drive using
>
> save ('E:\filename')
>
> and actually my file is saved on the E: directory,
> the only problem now being that in E: it is not
> stored as .mat file, but "Link to Microsoft Access Office".
> I don't know what to do, could you pls give me advice?

You likely installed or updated Microsoft Office since the last time you
associated the .MAT extension with MATLAB. My understanding is that
Microsoft Office automatically assumes that it should associate the .MAT
extension as a Microsoft Access Table shortcut. If you want to make sure
the file was saved correctly as a MAT-file that MATLAB can read, you can
check this by loading in the file using LOAD.

> Here is the step of my code where this problem occurs:
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> for l=1:N
>
> filename = num2str(l,'data_%d.mat');
>
> save ('E:\filename')

This isn't going to do what you want. It's going to save all your files as
a file named filename on your E drive, each one but the first overwriting
the previous. You want to use FULLFILE:


for k = 1:N
    filename = num2str(k,'data_%d.mat');
    save(fullfile('E:', filename))
end


[As a personal preference, I try to avoid using i, j, or lower case L as
loop indices. The former are too useful as sqrt(-1); the latter is too easy
to confuse with the number 1.]

--
Steve Lord
slord@mathworks.com


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

envelope graphic E-mail this page to a colleague

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.
Related Topics