Info

This question is closed. Reopen it to edit or answer.

"Clear" function is not evaluated properly once program converted to exe

1 view (last 30 days)
I have created an executable from my GUI program. However, I have used a line to clear from matlab memory old files:
clear function
While working in Matlab environment, everything is ok. However, once converted to executable the program does not properly evaluates that line. I can see this, because executable produces the same results for the loop, meaning that program keeps executing "function", while in Matlab environment that function is overwritten by a new function.
Does anybody knows how this issue could be solved?
  1 Comment
Jan
Jan on 14 Mar 2013
It is not clear, when "function" means your function name, and when it means the term function. Did you use clear YourFuncName or is it a typo and you want clear functions with a trailing 's'?

Answers (1)

Jan
Jan on 14 Mar 2013
You want a deployed function to write an M-function dynamically and evaluate it? What is exactly the difference between deployed and not-deployed functions then? Does this mean that it is trivial to emulate a locally installed Matlab just by a deployed tool, which write M-files dynamically and executes them? This would be rather strange and smell like a massive copyright problem, when running deployed code is allowed without owning a Matlab version. But perhaps I misunderstood something.
The most efficient way to solve this is to avoid the dynamic creation of M-files strictly. This would be a good idea for different reasons, e.g. to reduce the complexity, to allow for an easier debugging and to increase the efficiency.
  2 Comments
Tomas Iesmantas
Tomas Iesmantas on 14 Mar 2013
Not-deployed GUI: there is a loop and there is a txt file, say flow.txt. At every loop iteration it deletes everything from flow.txt, fills it with a set of new equations, converts to .m file and solves the equations in that file. After solution is obtained, the file extension is changed to .txt again. And the same is at each "for" loop iteration. However, I needed to write a line "clear Flow" within loop, so that at every new iteration Matlab would use new Flow.m file. Deployed (standalone) GUI: I assume, that executable file/program should do the same as net deployed GUI version. However, that standalone program, once triggered, does not create a new .m file - at least I cannot see any new files. However, the result of that seems to be solution of the same set of equations, while it should be different every time.
Jan
Jan on 18 Mar 2013
The deployed code should be able to create the M-file. I'd expect, that this M-file cannot be interpreted, but the deployed code runs only the M-files, which have been existing during the procedure of deployment - but this assumption could be wrong, although anything else would be rather strange.
How do you see, that the M-files are not created? Did you specify a folder where to save them?
Again I strongly recommend not to create M-code dynamically, because such meta-programming is a bad programming pattern. As you see, it causes more troubles than it solves.

This question is closed.

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!