Prev: .xls to .kcl
Next: help with the code
From: Rops ropss on 15 Jun 2010 09:52 I have an old file........old_file.dat from which I create a new file...............new_file.dat I now have to delete the old_file.dat(which is easy)........but have to rename the new one as old_file.dat...................or any other name....... Problem is : The process cannot rename the file as it is being used by other processes. the other processes is ofcourse MATLAB....i just have to let MATLAB to go of the file. I have tried everything.......onCleanup....clear......nothing is working except closing MATLAB and renaming the file manually. Please suggest what the problem is.Thanks for any help!!! Some info: To create the new_file from the old_file, I have defined a new function.
From: Steven Lord on 15 Jun 2010 10:09 "Rops ropss" <pratik.ropia(a)gmail.com> wrote in message news:hv80i5$evd$1(a)fred.mathworks.com... >I have an old file........old_file.dat from which I create a new >file...............new_file.dat > > I now have to delete the old_file.dat(which is easy)........but have to > rename the new one as old_file.dat...................or any other > name....... > > Problem is : The process cannot rename the file as it is being used by > other processes. > > the other processes is ofcourse MATLAB....i just have to let MATLAB to go > of the file. > I have tried everything.......onCleanup....clear......nothing is working > except closing MATLAB and renaming the file manually. > > Please suggest what the problem is.Thanks for any help!!! > > Some info: To create the new_file from the old_file, I have defined a new > function. And how do you "create the new_file from the old_file"? Do you FOPEN the new_file and the old_file, read data from old_file and write into new_file? If so, do you remember to FCLOSE _both_ files once you've finished using them? -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: Rops ropss on 15 Jun 2010 10:25 > And how do you "create the new_file from the old_file"? Do you FOPEN the > new_file and the old_file, read data from old_file and write into new_file? > If so, do you remember to FCLOSE _both_ files once you've finished using > them? Yup.... i fclose both files...still the same problem...here is the function %%%%%aa,path and filename come from other function %%%%%aa is a struct;;;;path and filename are strings %%%%%fid just to return something function [fid] = read_data_into_newfile(aa,path,filename) fid_new = fopen([path '\new_' filename],'w+'); fid_old = fopen([path '\' filename],'r'); while 1 temp_variable = fgetl(fid_old); k=1; if strcmp(strtok(temp_variable),aa.variable_names{1,1}) while k<=aa.number_of_var fprintf(fid_new,'%s %f\n',aa.variable_names{k,1},aa.variable_values(k,1)); if k<aa.number_of_var temp_variable = fgetl(fid_old); end k=k+1; end elseif feof(fid_old) fclose(fid_old); break else fprintf(fid_new,'%s \n', temp_variable); end end fclose(fid_new); clear fid_new fid_old temp_variable fid = k; return end
From: sscnekro on 15 Jun 2010 10:37 > Yup.... i fclose both files...still the same problem...here is the function Hi there, I 'd not swear on it, but if I remember well, I also had the problem of file not accesible due to processes running even after fclosing (in R2008b). If I'm not wrong, restarting ML was the only way of getting rid of that. But sorry, I have no time at the moment to verify it back again.
From: Rops ropss on 15 Jun 2010 10:58
> Hi there, I 'd not swear on it, but if I remember well, I also had the problem of file >not accesible due to processes running even after fclosing (in R2008b). If I'm not >wrong, restarting ML was the only way of getting rid of that. But sorry, I have no >time at the moment to verify it back again. I have R2010a on my system.....but dunno if it could be the same problem or not...... |