Calling .m file in app designer that will need to call another .m file to execute the code

I have a .m file (FILE 1) that calls a function. The function is written in another .m file(FILE). How do i press a button in GUI and run the FILE 1 which will eventually have to call FILE2 to be able to show an output in App Designer. I am a beginner in matlab app desiger and i am having trouble just executing the code.

 Accepted Answer

You can execute m-files by calling them by their name in your code. To ensure your app can find the scripts, either place them in the same folder as your app, of add the folder they are in to your MATLAB Path.
See this answer for a related example.

6 Comments

Thank you very much. It works now. I just have to set path and do the whole execution in Matlab.
However, when i tried to compile everything into an app and try running it. It doesn work.I have already compile the apps together with the files.
What does 'doesn't work' mean? What happens? If there are error messages, please share them (all the red text). You many need to create a log file for your app to capture the error messages. See this Answer for how to do that. Share the contents of your output here.
Error using trainNetwork (line 184)
Deployment of training progress plot not supported.
Error in testcode5 (line 38)
Error in run (line 91)
Error in testcodes/Testcode5ButtonPushed (line 56)
Error in appdesigner.internal.service.AppManagementService/tryCallback (line 181)
Error in matlab.apps.AppBase>@(source,event)tryCallback(appdesigner.internal.service.AppManagementService.instance(),app,callback,requiresEventData,event) (line 37)
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 427)
Error while evaluating Button PrivateButtonPushedFcn.
Hi Cris, this is what i received from the logfile.
The line i have written is just callng function : a = functionname ; The function that i tried to call uses statistic and machine learning toolbox and deep learning toolbox.
How are you using trainNetwork? Please share your Testcode5ButtonPushed callback function code. Also line 38 of testcode5.
For line 38 of testcode 5 :
net = trainNetwork(eval('X'),eval('Y'),lgraph1,options);
For testcode5ButtonPushed callback :
run('testcode5.m')
Not sure what your options are, but based on the error messages, you must have the 'plots' option set to 'training-progress', and apparently that is not supported for standalone apps (deployment).
Try changing your 'plots' option to 'none' and see if that allows your app to run.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!