3 ways to access your app handle
In these examples the app's name is "MyApp".
1. Store the app handle when you open the app.
This is the best approach.
For more info & demos on this method
2. Find the handle to an app that's already opened
The HandleVisibility of UIFigures is set to off by default which makes it a bit more difficult to find a UIFigure (or app) handle. The code below finds all figure handles and then isolates the figure belonging to your App.
This assumes you only have 1 figure opened with your App's name. For extra precaution, add a Tag to your App and include the tag in the search.
allfigs = findall(0,'Type', 'figure');
app2Handle = findall(allfigs, 'Name', 'MyApp');
app2Handle = findall(allfigs, 'Name', 'MyApp', 'Tag', 'MyUniqueTagName');
3. Make your app handle visible so it can be found with gcf()
Starting in r2020a, open your app in AppDesigner and set your app's HandleVisibility to 'on' or 'callback'. This can can either be done in the App's startup function using MyApp.UIFigure.HandleVisibility='on'; or it can be done in the Design View by selecting your figure handle from the component browser, then set HandleVisibility under the Parent/Child submenu to "on".
Be aware that your App's figure handle will now be available for any plotting function that's looking for the current figure which may lead to undesirable results. This method should be avoided.