Projecting a plot onto a second monitor through an App made in the App Designer.

30 views (last 30 days)
I am creating an app that dynamically changes plots based on inputs (which I have done) and projects the plot fullscreen onto a second monitor which also dynamically changes with the inputs.
I have made a livescript that is capable of projecting a plot fullscreen to a second monitor that dynamically changes, but I'm unsure how to accomplish this through App Designer. Is there is a way to have an App create a figure outside the app itself? From there I would be able to manipulate it to fill a second screen.
Thanks in advance

Accepted Answer

Kevin Holly
Kevin Holly on 27 Feb 2022
Edited: Kevin Holly on 27 Feb 2022
Yes. There are multiple ways of doing this with App Designer. Below are two approaches.
  1. You can write a callback function that generates a figure or uifigure when interactiving with one of the UI components (or have it appear using a startup function). Using the figure handle, you can change the position of the figure/uifigure as you have probably done so in your live script. One way to do this is to convert the figure units to normalize and then you can change the position of the figure accordingly, where a value greater than 1 would likely place the figure on the other monitor depending on your layout. You could also detect the screen resolution and set pixel coordinates this way. You could also change the WindowState to fullscreen or maximized. If you need any help with this approach let me know.
  2. You can use a multiwindow app approach (see link for more detailed instructions). Here, you create multiple apps that can communicate with one another using property variables, input arguments, and startup functions. When you create an app, you have the ability to make it maximized or fullscreen within the component browser when you select the UIFigure (see image below). You could use simliar approaches mentioned in #1 by programmatically adjusting the position or windowstate in a startup function for the app. Once again, if you need any more help with this let me know.
  2 Comments
Al Milne
Al Milne on 27 Feb 2022
Yes thank you Kevin this is exactly what I need! And indeed the first approach with the normalised figure position and fullscreened window state is how I've done it in the live script.
I've since generated a figure in a startup function and now am running into difficulties using that same previously generated figure to plot the changing user defined inputs through the UI components.
Unless I redefine my figure and axis handle within the callback for a specific UI Component the axis I'm trying to plot to goes unrecognised, and if I do redefine it I end up just creating a new figure with each change of the UI Component rather than updating what is being displayed on the previously existing figure from the startup function.
Is there any insight you can give me?
Thanks a lot.
Kevin Holly
Kevin Holly on 28 Feb 2022
Al,
I attached an example app. You will need to make sure your axes handle is defined as a property variable (please see code in the app attached).
Alternatively, you could define your figure handle as a property variable.
properties (Access = private)
figurehandle
end
function startupFcn(app)
figurehandle = uifigure;
figurehandle.Units = "normalized";
figurehandle.Position = [1 0 2 1];
figurehandle.WindowState = "fullscreen";
uiaxes(secondwindow);
end
Then when your UI component is activated, the callback function could be
function ButtonPushed(app, event)
plot(app.figurehandle.Children,x,y) % Assuming there is only one child for the figure and it is an axes
end

Sign in to comment.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer 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!