<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156493</link>
    <title>MATLAB Central Newsreader - M files must be run twice for changes to take effect on linux system</title>
    <description>Feed for thread: M files must be run twice for changes to take effect on linux system</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 20 Sep 2007 20:28:24 -0400</pubDate>
      <title>M files must be run twice for changes to take effect on linux system</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156493#393277</link>
      <author>Tim</author>
      <description>Weird question. Running Matlab r2006a on  a 64bit linux&lt;br&gt;
system I ran into the following. Whenever I change something&lt;br&gt;
in an m-file, the first time I then call it from the command&lt;br&gt;
window it will not include the changes just made. I will&lt;br&gt;
need to run it again, to have it updated. &lt;br&gt;
&lt;br&gt;
This is not only a hassle but also very problematic when&lt;br&gt;
checking for bugs, or developing code in general. I never&lt;br&gt;
had this before (I've ran various Matlab versions on both&lt;br&gt;
windows, linux and unix over the last years) and I'm pretty&lt;br&gt;
much clueless as to where this might be coming from.&lt;br&gt;
&lt;br&gt;
Thanks for any input!</description>
    </item>
    <item>
      <pubDate>Thu, 20 Sep 2007 22:38:07 -0400</pubDate>
      <title>Re: M files must be run twice for changes to take effect on linux system</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156493#393297</link>
      <author>Dan Haeg</author>
      <description>&quot;Tim &quot; &amp;lt;timtjanssen@yahoo.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;fcul58$kac$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Weird question. Running Matlab r2006a on  a 64bit linux&lt;br&gt;
&amp;gt; system I ran into the following. Whenever I change something&lt;br&gt;
&amp;gt; in an m-file, the first time I then call it from the command&lt;br&gt;
&amp;gt; window it will not include the changes just made. I will&lt;br&gt;
&amp;gt; need to run it again, to have it updated. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; This is not only a hassle but also very problematic when&lt;br&gt;
&amp;gt; checking for bugs, or developing code in general. I never&lt;br&gt;
&amp;gt; had this before (I've ran various Matlab versions on both&lt;br&gt;
&amp;gt; windows, linux and unix over the last years) and I'm pretty&lt;br&gt;
&amp;gt; much clueless as to where this might be coming from.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks for any input!&lt;br&gt;
&lt;br&gt;
I ran into a similar problem on windows. I wrote a function&lt;br&gt;
that writes a script using fprintf. The last line in the&lt;br&gt;
function runs the script which has been closed with fclose.&lt;br&gt;
It does not run the current version of the script though. If&lt;br&gt;
I run the script from the command line the current one gets run.</description>
    </item>
    <item>
      <pubDate>Fri, 21 Sep 2007 12:36:41 -0400</pubDate>
      <title>Re: M files must be run twice for changes to take effect on linux system</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156493#393359</link>
      <author>Malcolm Lidierth</author>
      <description>Have you tried:&lt;br&gt;
&amp;gt;&amp;gt;clear functionname&lt;br&gt;
Also see help inmem&lt;br&gt;
&lt;br&gt;
Is the fucntion a callback?</description>
    </item>
    <item>
      <pubDate>Fri, 21 Sep 2007 13:43:53 -0400</pubDate>
      <title>Re: M files must be run twice for changes to take effect on linux</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156493#393370</link>
      <author>Gordon Weast</author>
      <description>Tim,&lt;br&gt;
&lt;br&gt;
Try executing 'clear functions' at the MATLAB prompt after you edit&lt;br&gt;
the file.  That will clean out any cached versions of m files.&lt;br&gt;
&lt;br&gt;
If you create a new file and put it down in the MATLABROOT/toolbox/...&lt;br&gt;
tree somewhere, then you need to rehash or the file won't be found.&lt;br&gt;
&lt;br&gt;
Gordon Weast&lt;br&gt;
xPC Target Development&lt;br&gt;
The MathWorks&lt;br&gt;
&lt;br&gt;
Tim wrote:&lt;br&gt;
&amp;gt; Weird question. Running Matlab r2006a on  a 64bit linux&lt;br&gt;
&amp;gt; system I ran into the following. Whenever I change something&lt;br&gt;
&amp;gt; in an m-file, the first time I then call it from the command&lt;br&gt;
&amp;gt; window it will not include the changes just made. I will&lt;br&gt;
&amp;gt; need to run it again, to have it updated. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; This is not only a hassle but also very problematic when&lt;br&gt;
&amp;gt; checking for bugs, or developing code in general. I never&lt;br&gt;
&amp;gt; had this before (I've ran various Matlab versions on both&lt;br&gt;
&amp;gt; windows, linux and unix over the last years) and I'm pretty&lt;br&gt;
&amp;gt; much clueless as to where this might be coming from.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks for any input!</description>
    </item>
    <item>
      <pubDate>Sat, 01 Dec 2007 05:23:29 -0500</pubDate>
      <title>Re: M files must be run twice for changes to take effect on linux</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156493#404052</link>
      <author>Tim</author>
      <description>Thanks all for the input. Sorry for not getting back sooner.&lt;br&gt;
Yes, with 'clear functions' problem is solved. I actually&lt;br&gt;
was already using that. However, I don't understand why I&lt;br&gt;
should use that, when I never had to before.&lt;br&gt;
&lt;br&gt;
It turns out that the problem occurs with functions that are&lt;br&gt;
in a different directory than from which I'm working&lt;br&gt;
(running the primary script). For some of my programs I have&lt;br&gt;
functions in subdirectories that I usually don't add to the&lt;br&gt;
path, but simply jump through the directory structure using&lt;br&gt;
'cd' commands. That alway worked fine, but these are the&lt;br&gt;
ones that are problematic on my present matlab system. Is&lt;br&gt;
there a simple explanation for this? Or is this just a&lt;br&gt;
not-so-good programming practice? I can of course add the&lt;br&gt;
directory structure to the path when calling the script and&lt;br&gt;
be done with it (and remove after running), but just like to&lt;br&gt;
know what's causing the problems that were never there before.&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
&lt;br&gt;
Tim&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Gordon Weast &amp;lt;gweast@mathworks.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;fd0hqp$4s2$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Tim,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Try executing 'clear functions' at the MATLAB prompt after&lt;br&gt;
you edit&lt;br&gt;
&amp;gt; the file.  That will clean out any cached versions of m files.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; If you create a new file and put it down in the&lt;br&gt;
MATLABROOT/toolbox/...&lt;br&gt;
&amp;gt; tree somewhere, then you need to rehash or the file won't&lt;br&gt;
be found.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Gordon Weast&lt;br&gt;
&amp;gt; xPC Target Development&lt;br&gt;
&amp;gt; The MathWorks&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Tim wrote:&lt;br&gt;
&amp;gt; &amp;gt; Weird question. Running Matlab r2006a on  a 64bit linux&lt;br&gt;
&amp;gt; &amp;gt; system I ran into the following. Whenever I change something&lt;br&gt;
&amp;gt; &amp;gt; in an m-file, the first time I then call it from the command&lt;br&gt;
&amp;gt; &amp;gt; window it will not include the changes just made. I will&lt;br&gt;
&amp;gt; &amp;gt; need to run it again, to have it updated. &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; This is not only a hassle but also very problematic when&lt;br&gt;
&amp;gt; &amp;gt; checking for bugs, or developing code in general. I never&lt;br&gt;
&amp;gt; &amp;gt; had this before (I've ran various Matlab versions on both&lt;br&gt;
&amp;gt; &amp;gt; windows, linux and unix over the last years) and I'm pretty&lt;br&gt;
&amp;gt; &amp;gt; much clueless as to where this might be coming from.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Thanks for any input!</description>
    </item>
    <item>
      <pubDate>Mon, 02 Mar 2009 15:09:01 -0500</pubDate>
      <title>Re: M files must be run twice for changes to take effect on linux</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156493#631898</link>
      <author>Seth </author>
      <description>I had exactly this same problem (R2008b on mac), where I wrote a .m file as output from a script, and then ran it both using the &quot;run&quot; command and by opening it up in the editor and choosing &quot;Run...&quot;. The only way it would recognize the change was to either modify the .m script in the editor (even if the &quot;new&quot; file was written), or to use the &quot;clear functions&quot; command.&lt;br&gt;
&lt;br&gt;
Matlab ought to at least check the modification dates of files it runs to determine whether it can use cached versions. Having to know about and exectue &quot;clear functions&quot; is not acceptable.&lt;br&gt;
&lt;br&gt;
It's fortunate that I found this thread about MATLAB's buggy m-file running behavior. Hopefully others encountering this problem will be able to find this solution, too.  If nothing else, the help for 'run' should include something about this.&lt;br&gt;
&lt;br&gt;
&quot;Tim &quot; &amp;lt;timtjanssen@yahoo.com&amp;gt; wrote in message &amp;lt;fiqr4h$44t$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Thanks all for the input. Sorry for not getting back sooner.&lt;br&gt;
&amp;gt; Yes, with 'clear functions' problem is solved. I actually&lt;br&gt;
&amp;gt; was already using that. However, I don't understand why I&lt;br&gt;
&amp;gt; should use that, when I never had to before.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; It turns out that the problem occurs with functions that are&lt;br&gt;
&amp;gt; in a different directory than from which I'm working&lt;br&gt;
&amp;gt; (running the primary script). For some of my programs I have&lt;br&gt;
&amp;gt; functions in subdirectories that I usually don't add to the&lt;br&gt;
&amp;gt; path, but simply jump through the directory structure using&lt;br&gt;
&amp;gt; 'cd' commands. That alway worked fine, but these are the&lt;br&gt;
&amp;gt; ones that are problematic on my present matlab system. Is&lt;br&gt;
&amp;gt; there a simple explanation for this? Or is this just a&lt;br&gt;
&amp;gt; not-so-good programming practice? I can of course add the&lt;br&gt;
&amp;gt; directory structure to the path when calling the script and&lt;br&gt;
&amp;gt; be done with it (and remove after running), but just like to&lt;br&gt;
&amp;gt; know what's causing the problems that were never there before.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Tim&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Gordon Weast &amp;lt;gweast@mathworks.com&amp;gt; wrote in message&lt;br&gt;
&amp;gt; &amp;lt;fd0hqp$4s2$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Tim,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Try executing 'clear functions' at the MATLAB prompt after&lt;br&gt;
&amp;gt; you edit&lt;br&gt;
&amp;gt; &amp;gt; the file.  That will clean out any cached versions of m files.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; If you create a new file and put it down in the&lt;br&gt;
&amp;gt; MATLABROOT/toolbox/...&lt;br&gt;
&amp;gt; &amp;gt; tree somewhere, then you need to rehash or the file won't&lt;br&gt;
&amp;gt; be found.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Gordon Weast&lt;br&gt;
&amp;gt; &amp;gt; xPC Target Development&lt;br&gt;
&amp;gt; &amp;gt; The MathWorks&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Tim wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Weird question. Running Matlab r2006a on  a 64bit linux&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; system I ran into the following. Whenever I change something&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; in an m-file, the first time I then call it from the command&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; window it will not include the changes just made. I will&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; need to run it again, to have it updated. &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; This is not only a hassle but also very problematic when&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; checking for bugs, or developing code in general. I never&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; had this before (I've ran various Matlab versions on both&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; windows, linux and unix over the last years) and I'm pretty&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; much clueless as to where this might be coming from.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Thanks for any input!&lt;br&gt;
&amp;gt; </description>
    </item>
    <item>
      <pubDate>Mon, 02 Mar 2009 16:08:05 -0500</pubDate>
      <title>Re: M files must be run twice for changes to take effect on linux</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156493#631927</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;Seth &quot; &amp;lt;neologism+matlab@gmail.com&amp;gt; wrote in message &lt;br&gt;
news:gogsqd$pbe$1@fred.mathworks.com...&lt;br&gt;
&amp;gt;I had exactly this same problem (R2008b on mac), where I wrote a .m file as &lt;br&gt;
&amp;gt;output from a script, and then ran it both using the &quot;run&quot; command and by &lt;br&gt;
&amp;gt;opening it up in the editor and choosing &quot;Run...&quot;. The only way it would &lt;br&gt;
&amp;gt;recognize the change was to either modify the .m script in the editor (even &lt;br&gt;
&amp;gt;if the &quot;new&quot; file was written), or to use the &quot;clear functions&quot; command.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Matlab ought to at least check the modification dates of files it runs to &lt;br&gt;
&amp;gt; determine whether it can use cached versions. Having to know about and &lt;br&gt;
&amp;gt; exectue &quot;clear functions&quot; is not acceptable.&lt;br&gt;
&lt;br&gt;
Where did you save this M-file?  If you saved it in a directory under &lt;br&gt;
$MATLABROOT/toolbox, then we strongly recommend you save it elsewhere.&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_env/f8-28521.html&quot;&gt;http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_env/f8-28521.html&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
If you didn't save it under the toolbox directory, did you save it on a &lt;br&gt;
network drive?  If the network drive doesn't inform MATLAB that the file has &lt;br&gt;
changed promptly (or at all), MATLAB may not learn that the function has &lt;br&gt;
changed until you clear it from memory, at which time MATLAB has to ask the &lt;br&gt;
network drive for a new copy of the function to load into memory.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com </description>
    </item>
    <item>
      <pubDate>Mon, 30 Mar 2009 03:53:01 -0400</pubDate>
      <title>Re: M files must be run twice for changes to take effect on linux</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156493#638575</link>
      <author>Seth </author>
      <description>No, I saved it in a local directory, outside of any of the MATLAB (or my personal) paths. The exact path was something like '/Users/seth/_code/imc/suolson.m'; the file essentially creates a bunch of variables in the local workspace. Calling &lt;br&gt;
run('/Users/seth/_code/imc/suolson.m')&lt;br&gt;
would work the first time after 'clear functions' or after launching MATLAB. However, calling 'run' again, after the data had been changed outside of MATLAB, did nothing. Even after I opened it in MATLAB's editor and pressed the 'run' button used the contents of the file before it had been modified. (I deleted the local workspace variables before doing this, just to make sure it actually was running.)&lt;br&gt;
&lt;br&gt;
With the previously mentioned workarounds, and with my beginning to transition to other data analysis and plotting utilities, the issue is less important to me now.&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
Seth&lt;br&gt;
&lt;br&gt;
&quot;Steven Lord&quot; &amp;lt;slord@mathworks.com&amp;gt; wrote in message &amp;lt;goh095$dlk$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Where did you save this M-file?  If you saved it in a directory under &lt;br&gt;
&amp;gt; $MATLABROOT/toolbox, then we strongly recommend you save it elsewhere.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_env/f8-28521.html&quot;&gt;http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_env/f8-28521.html&lt;/a&gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; If you didn't save it under the toolbox directory, did you save it on a &lt;br&gt;
&amp;gt; network drive?  If the network drive doesn't inform MATLAB that the file has &lt;br&gt;
&amp;gt; changed promptly (or at all), MATLAB may not learn that the function has &lt;br&gt;
&amp;gt; changed until you clear it from memory, at which time MATLAB has to ask the &lt;br&gt;
&amp;gt; network drive for a new copy of the function to load into memory.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; -- &lt;br&gt;
&amp;gt; Steve Lord&lt;br&gt;
&amp;gt; slord@mathworks.com &lt;br&gt;
&amp;gt; </description>
    </item>
  </channel>
</rss>

