Thread Subject: Update M File

Subject: Update M File

From: Brendan Klare

Date: 14 Mar, 2010 13:53:02

Message: 1 of 3

I often will edit a matlab m file on one computer, and copy the file to a machine that is more powerful and has more resources for execution. However, I am having the following incredibly frustrating problem: many times the when I copy over an old version of an m-file with a new version, the code from the old version is run instead. I believe this has to do with the compilation of the m files, i.e. there is some intermediate code file from the old m code (.asv I think) that is being run instead of the new m code. I had been calling the 'rehash' command recently, which seemed to work better (i.e. my new code was run often than before), but I still have cases when the old code is run instead. I have also tried the refresh command with no success.

Does anyone know a resolution to this problem? It is insanely frustrating to run a program that takes one hour, only to find out afterwards it ran the old version of the code.

Subject: Update M File

From: John D'Errico

Date: 14 Mar, 2010 14:14:04

Message: 2 of 3

"Brendan Klare" <bklare@gmail.com> wrote in message <hnipnu$o7$1@fred.mathworks.com>...
> I often will edit a matlab m file on one computer, and copy the file to a machine that is more powerful and has more resources for execution. However, I am having the following incredibly frustrating problem: many times the when I copy over an old version of an m-file with a new version, the code from the old version is run instead. I believe this has to do with the compilation of the m files, i.e. there is some intermediate code file from the old m code (.asv I think) that is being run instead of the new m code. I had been calling the 'rehash' command recently, which seemed to work better (i.e. my new code was run often than before), but I still have cases when the old code is run instead. I have also tried the refresh command with no success.
>
> Does anyone know a resolution to this problem? It is insanely frustrating to run a program that takes one hour, only to find out afterwards it ran the old version of the code.

Where do you put these files?

Do NOT place them in the MATLAB toolbox directories,
as those files are not seen until MATLAB restarts.

I once wrote a function to sync a set of directories,
downloading only those files that are new. I should
look to see where it is.

John

Subject: Update M File

From: Jan Simon

Date: 14 Mar, 2010 14:34:05

Message: 3 of 3

Dear Brendan!

> I often will edit a matlab m file on one computer, and copy the file to a machine that is more powerful and has more resources for execution. However, I am having the following incredibly frustrating problem: many times the when I copy over an old version of an m-file with a new version, the code from the old version is run instead. I believe this has to do with the compilation of the m files, i.e. there is some intermediate code file from the old m code (.asv I think) that is being run instead of the new m code. I had been calling the 'rehash' command recently, which seemed to work better (i.e. my new code was run often than before), but I still have cases when the old code is run instead. I have also tried the refresh command with no success.
>
> Does anyone know a resolution to this problem? It is insanely frustrating to run a program that takes one hour, only to find out afterwards it ran the old version of the code.

The .asv files are just backups of the M-files and they are not used for processing. But there are copies of the M-files in the memory. Usually they are replaced if newer versions of the files are available, but this may fail if you work on a network drive and the "change notification handles" of the operating system are exhausted. Fortunately there is a tool which never fails to remove the M-functions from the memory: CLEAR.
Either clear the specific file, e.g. myFunc.m:
  clear myFunc
or all functions:
  clear functions

Did you try "rehash pathreset" ? I'd expected, that this works well. But I'd rely on CLEAR.

Good luck, Jan

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
compile Brendan Klare 14 Mar, 2010 09:54:07
update code Brendan Klare 14 Mar, 2010 09:54:07
rssFeed for this Thread

Contact us at files@mathworks.com