App Designer: How to pass script using object/class -methods, working in main Workspace, to function?
Show older comments
I am using App Designer to make a simplified GUI for a Simulink application/software Sim with complicated GUI.
Running the application Sim generates a class (in the main Workspace) called sim.
This sim is a top level class (handle) and have several methods like
'loadModel', 'runAnalysis', 'saveresult', etc
Programmatically it works to run the application and use the methods in a script like

The complicated GUI appears, gets filled with data and is run correctly. It works well!
Now I want to run this script from within a function in my simplified GUI/App Designer. Pushing a buttom is supposed to run the script.

As you can see I am following Create Multiwindow Apps in App Designer - MATLAB & Simulink - MathWorks Nordic when it comes to using several windows.
Hitting the push buttom makes the complicated GUI appear, then Matlab stops with message: ’Unable to resolve the name sim.loadModel’.
I somehow need to pass the object definition (or the methods) into the function. This object 'sim' seems to be ‘public’ and can be seen in the main workspace as soon as the application ‘Sim’ is run.
Can this be done in the function startupFcn(app)?
Am I using the wrong arguments in the function call?
Answers (1)
Gert Persson
on 17 Jun 2021
0 votes
Categories
Find more on Debugging and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!