> How to share a value in a field of an app with another app?
If you have access to the app's handle or the app's figure handle, then you have access to all app components within the app. See also Matlab's documentation on multi-window apps. Solution 1: store the app handle
If you invoke app #2 from within app #1 you can gain access to both apps by storing and passing the app handles. For example, within the startupFcn or within any callback function of app #1, open app #2 and store its handle.
For more info & demos on this method
Solution 2: find the handle to the app's figure
The HandleVisibility of UIFigures is set to off by default which makes it a bit difficult to find a UIFigure handle. The code below finds all figure handles and then isolates the handle that belongs to your app.
allfigs = findall(0,'Type','figure');
app2Handle = findall(allfigs, 'Name', 'MyApp');
Importantly, "MyApp" in the example above is the name of the app's figure (not necessarily the name of the app). It requires a unique name that can be distinguished from any other figure name.
To name your app's figure,
- open your app in AppDesigner and go to Design View
- Select the figure background or the top-most component in the Component Browser
- From the Inspector list of properties, scroll down to "Identifiers"
- use the "Name" property to name your app's figure. This name will appear in your new app figure.
Make the app handle available from anywhere within the app.