Filter löschen
Filter löschen

GUI exe problem running external m file

9 Ansichten (letzte 30 Tage)
Tonghui Zhang
Tonghui Zhang am 9 Mai 2019
Kommentiert: Tonghui Zhang am 5 Jun. 2020
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

Antworten (3)

Walter Roberson
Walter Roberson am 9 Mai 2019
Bearbeitet: Walter Roberson am 9 Mai 2019
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 Kommentare
Walter Roberson
Walter Roberson am 5 Jun. 2020
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
Gideon Tang am 5 Jun. 2020
Thanks Walter

Melden Sie sich an, um zu kommentieren.


Gideon Tang
Gideon Tang am 5 Jun. 2020
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 Kommentare
Gideon Tang
Gideon Tang am 5 Jun. 2020
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
Tonghui Zhang
Tonghui Zhang am 5 Jun. 2020
Hi,
If the script is certain you can compile it together with your main file. If you the end users only have access to the modification of t, I think you can edit as an input data by a text component in GUI and transfer it to your script.
if you want to use a standalone compiled gui without matlab to run the script, I do not think it is possible.
BR
Yours Zhang

Melden Sie sich an, um zu kommentieren.


Gideon Tang
Gideon Tang am 5 Jun. 2020
Hi Tonghui,
Thanks anyway.

Kategorien

Mehr zu C Shared Library Integration finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by