I have built an app in App Designer, but it is missing some necessary functionality. I would like to replicate the spacing on my GUIDE app using the positional vectors defined in the App Designer Code. Can I use the "Position" vectors from "App Designer" as the "OuterPosition" vectors in GUIDE?
MATLAB: Can I format a GUIDE app’s axes given positional vectors defined in an App Designer app
MATLAB
Related Solutions
As of MATLAB R2020a, the "linkaxes" and "linkprop" functionalities are not supported using uifigure in App Designer. Our development team has been notified of this enhancement, and will consider it for future releases of MATLAB.
In the meantime, starting in MATLAB R2020a, you can use regular Axes within App Designer, and both "linkprop" and "linkaxes" are fully supported by regular axes when used within App Designer. Note that, in order to create a regular axes in App Designer, you need to programmatically call the "axes" command. My recommendation is to create a panel in your App while designing your app, and then use that panel as the parent for the axes.
A simple example about how to use regular Axes in an app written in App Designer is as follows:
1. Create a new app.
2. Drag a panel into your app where you want your axes. Set the "Title" to empty to remove the title from the panel. You can also change the border if desired.
3. Add a new property called "Axes", as follows:
properties Axes matlab.graphics.axis.Axesend
4. In the "Code View", create a new Callback for the the UIFigure's StartupFcn.
5. Add this code to the new "startupFcn" (please note that both the signature and the end of the function will be generated automatically by App Designer for you)
function startupFcn(app) app.Axes = axes(app.Panel);end
You can then use "linkaxes" and "linkprop" on the app.Axes property.
The 'UIAxes' object does not have an object property similar to that of the 'ButtonDownFcn' for 'Axes' objects.
In addition, 'Axes' objects do not have a property related to hovering the cursor over the axis.
However, both of these goals can be met by use of 'UIFigure' callbacks. You can use the following steps
1) Establish UIFigure callback -
There is a small walkthrough of how to use 'UIFigure' callbacks within the following documentation.
If you would like a full list of the UIFigure callbacks, they can be found within the following documentation.
2) Access the cursor location -
We can use the following code within the callback function.
Coordinates = event.Source.CurrentPoint;
'Coordinates' now stores an array containing the coordinates of the cursor in units of pixels.
3.) Compare these coordinates to the location of the 'UIAxes' -
We can extract the position of the UIAxes using the 'Position' property. For example
Position=app.UIAxes.Position; %Get the axes position
This workflow is demonstrated in the attached example. The circle in the graph moves with the cursor and grows larger whenever you click within the area of the plot.
Best Answer