Problems updating variables from java generated m-files
1 view (last 30 days)
To analyse the output of one program, I have written a Java program that reads the output and write it to a series of m-files that contain two variables each.
In Matlab I read each series of m-files and plot it to visualize the data.
My problem is that Matlab are keeping old versions of the variables in stead of updating when reading the files. It gets an old version of the correct variable (from the correct file)
- I get no error message
- The file are flushed and closed in Java
- When I look at the m-files in the Matlab editor, they are indeed updated.
- If I alter one of the files and save it, Matlab reads the updated version of all the files in that directory.
- If I restart Matlab, the updated versions of all files are read.
- I use the 'run' function in Matlab to execute the m-files
- It seems like Matlab store an old version of the two variables for each file, and does not update from file.
I do not understand this, can anyone help me?
Jan on 1 May 2011
WHile REHASH and CLEAR FUNCTIONS concerns all functions in the PATH and all currently loaded functions, this touchs the specific function only:
with setting FuncName to the name of the created M-files.
Creating M-files is a very inefficient method in Matlab, if you want to provide values. It would be more stable to create a data file in ASCII or binary format.
More Answers (2)
Jarrod Rivituso on 1 May 2011
Sounds like MATLAB isn't aware a file has changed, and might be using an old, cached version of it.
Two thoughts you might try...
- Have MATLAB refresh function and file system path caches
- Try to clear all things from memory (rehash might do this automatically, I'm not sure)