필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

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

조회 수: 1 (최근 30일)
Tomas Iesmantas
Tomas Iesmantas 2013년 3월 14일
마감: MATLAB Answer Bot 2021년 8월 20일
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
Jan
Jan 2013년 3월 14일
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'?

답변 (1개)

Jan
Jan 2013년 3월 14일
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
Tomas Iesmantas
Tomas Iesmantas 2013년 3월 14일
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 2013년 3월 18일
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.

이 질문은 마감되었습니다.

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by