n o s p a m p l e a s e <nospam.please@alum.com> wrote in
message <77024167-c932-4c22-8180-
4335c6a1ecf1@s50g2000hsb.googlegroups.com>...
> I have a code that looks as follows:
>
> ---------------mytest.m--------------
> clear all;
>
> delete report.txt
>
> fid = fopen('report.txt','a');
> fprintf(fid, '\n %7d',refBus);
> fclose(fid);
> ----------------------------------------
>
> In the above code deletion of report.txt is not carried
out. I get the
> warning below.
>
> Warning: File not found or permission denied
>
> Even manually I cannot delete this file unless I close
Matlab. What
> can I do to delete this file without closing Matlab?
>
> NSP
In article <77024167-c932-4c22-8180-4335c6a1ecf1@s50g2000hsb.googlegroups.com>,
n o s p a m p l e a s e <nospam.please@alum.com> wrote:
>I have a code that looks as follows:
>In the above code deletion of report.txt is not carried out. I get the
>warning below.
>Warning: File not found or permission denied
You would get that if the file is already open within Matlab (or
within any other program.) Windows does not allow files to be deleted
if a process has them open.
--
"The study of error is not only in the highest degree
prophylatic, but it serves as a stimulating introduction to the
study of truth." -- Walter Lipmann
"Walter Roberson" <roberson@ibd.nrc-cnrc.gc.ca> wrote in message
news:g1ml7u$h5g$1@canopus.cc.umanitoba.ca...
> In article
> <77024167-c932-4c22-8180-4335c6a1ecf1@s50g2000hsb.googlegroups.com>,
> n o s p a m p l e a s e <nospam.please@alum.com> wrote:
>>I have a code that looks as follows:
>
>>---------------mytest.m--------------
>>clear all;
>>
>>delete report.txt
>>
>>fid = fopen('report.txt','a');
>>fprintf(fid, '\n %7d',refBus);
>>fclose(fid);
>>----------------------------------------
>
>>In the above code deletion of report.txt is not carried out. I get the
>>warning below.
>
>>Warning: File not found or permission denied
>
> You would get that if the file is already open within Matlab (or
> within any other program.) Windows does not allow files to be deleted
> if a process has them open.
To expand on Walter's diagnosis, if your code errored at some point after
you FOPENed the file but before you FCLOSEd it (say as you were working on
creating your code), it would still be open. Use FOPEN with the 'all' flag
to determine if this is the case and use FCLOSE on the obtained fids if it
is.
--
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.
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.