GUI exe problem running external m file
7 ビュー (過去 30 日間)
古いコメントを表示
Hi guys,
I am confronted with a probelm related to gui and exe. When I use run command in my GUI, it works well. But after I generated an exetutable program(exe), the run function report that the specified m file cannot be found. When I use a constant path to the run function. It reports that the m script cannot be executed. But the problem is that I can run it very well in guide. Are there anyone can help me?
Thanks a lot
0 件のコメント
回答 (3 件)
Walter Roberson
2019 年 5 月 9 日
編集済み: Walter Roberson
2019 年 5 月 9 日
You will never be able to use run() with MATLAB Compiler or Coder products. run() relies upon eval()
You will need to put the script onto your path and then refer to it by fixed name. It would then be compiled into the executable.
If the intent is to permit the user to provide executable matlab code then you will need to give up on that possibility.
If the need is for an initialization file that assigns only numeric constants or character vectors with no computation then I recommend looking in the file exchange for one of the programs that reads init files, which are data files rather than code.
7 件のコメント
Walter Roberson
2020 年 6 月 5 日
There is no possibility that you will ever be permitted to use a user-provided matlab file with MATLAB Compiler or MATLAB Coder. NONE.
If users were permitted to run arbitrary matlab code then every free-to-distribute runtime license would be able to do nearly everything that a paid version could do.
The interface contract (Terms of Use) is that someone with an appropriate paid license builds something very specific that is not extensible, and in return they can compile and distribute that specialized thing with a royalty free license.
providing user ability to extend with matlab code would be a direct violation of the terms of use for the Compiler product.
Specialized code that does not duplicate matlab functionality: Yup, can (typically) be compiled and distributed free (or however much you want to charge)
Code that can be extended with user-provided matlab: forbidden by the Compiler license, end user must have full matlab license instead.
Gideon Tang
2020 年 6 月 5 日
Hi Tonghui,
Thanks for your reply. May I ask is your code is a script with some specific outputs? Or just some input parameters and data? As my intent is to let the end-users to modify the file by themselves. My m. file is a simple script with some simple calculations and the results need to be callback into main compiled program. Do you think it is possible to achieve this by using "eval" function?
WR,
Gideon
5 件のコメント
Gideon Tang
2020 年 6 月 5 日
Dear Tonghui,
Thanks for your reply. So you compiled "a" file into the program? Or end-users can change the "a" file as an independent external file (which means you did not compile it)? Actually I have tried to use "eval" replace "run" function, but it does not work. For example, I have an external file (named "Input.m"), the script is:
Sint=sin(t); Cost=cos(t);
The parameter "t" is given by main program. I use a pushbutton1 to load the "Input" file (with the full path and file name), and pushbutton2 to "run" it to get the value of Sint and Cost, and plot them. It works well. However, if I do not use the "run" function and use "eval" function instead in pushbutton2, I cannot obtain the Sint and Cost value (even in guide).
Yours,
Gideon
参考
カテゴリ
Help Center および File Exchange で C Shared Library Integration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!