Prev: Rounding Values
Next: reverse the color map
From: us on 12 Jun 2010 18:17 "Adam " > Here is my file import function: > > fid2=fopen('feval.m','w'); > %Stuff that is always there. > fprintf(fid2,'%s \n','function [t,p]=testfun(x)'); > fprintf(fid2,'%s \n','%Test1'); > ...Print my new imported functions here... > fprintf(fid2,'%s \n','end') > fclose(fid2) well... this is NOT what you told CSSM in your OP - and explains the behavior - you access the newly created file before you close/flush it... us
From: dpb on 12 Jun 2010 18:30 Adam wrote: > Sorry I missed your last post. The buffer sounds like it's likely the > problem. I'll look into to how to flush it. Close the file... :) Note that if you're editing m-files and execute a given function that Matlab caches so you'll want to do a clear yourupdatedfunction to ensure you get the modified version as well. --
From: dpb on 12 Jun 2010 18:39 dpb wrote: .... > ... if you're editing m-files and execute a given function that > Matlab caches so you'll want to do a > > clear yourupdatedfunction > > to ensure you get the modified version as well _before_ opening and reading the new file. --
From: Adam on 14 Jun 2010 14:14 dpb <none(a)non.net> wrote in message <hv12ff$4ai$3(a)news.eternal-september.org>... > dpb wrote: > ... > > ... if you're editing m-files and execute a given function that > > Matlab caches so you'll want to do a > > > > clear yourupdatedfunction > > > > to ensure you get the modified version as well > > _before_ opening and reading the new file. > > -- Thanks, I'm clearing the functions now and it seems to be working.
From: Jan Simon on 14 Jun 2010 15:01
Dear Adam! > fid2=fopen('feval.m','w'); Be careful! If there is no file called "feval.m" in the current directory, you overwrite FEVAL.M of Matlab's toolbox. Beside this, it is not a good idea to re-use names used by Matlab functions, because the shadowing usually results in problems which are hard to debug. Calling automatically created M-files is inefficient in Matlab, because parsing a function needs a lot of overhead time. If the new function is called repeatedly afterwards, this timing problem gets smaller. Anyhow, I'd avoid this technique whenever it is possible. Search in this newsgroup for "evil eval" to learn more about the possible dangers. Good luck, Jan |