Problems updating variables from java generated m-files
1 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
Jan
2011-5-1
WHile REHASH and CLEAR FUNCTIONS concerns all functions in the PATH and all currently loaded functions, this touchs the specific function only:
clear(FuncName)
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.
更多回答(2 个)
Jarrod Rivituso
2011-5-1
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
rehash
- Try to clear all things from memory (rehash might do this automatically, I'm not sure)
clear functions
0 个评论
Henry
2012-7-4
Thanks! I had this same problem and had just been dealing with it for ages. I just put a clear(mfile) where mfile is the name of the mfile I was reading.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!