Defining the Parent location of a UIAxes plot
Show older comments
Hi all,
This is a continuation of a project I'm working on that started over in [this] thread. I've created a script that generates a "moving message display" utilizing the text displays in a plot window, but now I'm taking it a step further by creating an app to house that code. I'm specifically running into a problem with trying to set the Parent location for the UIAxes plot. The app designer is throwing an error thinking that I'm trying to use the RightPanel as an index, but that's where I want the UIAxes plot to reside instead of generating in a new figure window, so I thought I needed to define the Parent location... Is there something glaringly wrong with my code?
Thanks for the help!

function RunButtonPushed(app, event)
% Gather User Inputs from Left Panel of the GUI
% Set Background and Text Colors according to the button selected by the User
bgColor = app.BackgroundColorButtonGroup.SelectedObject.Tag;
txtColor = app.TextColorButtonGroup.SelectedObject.Tag;
msg = app.MessageEditField.Value; % Set the desired Message
if isempty(msg) % If the User does not specify a message
msg = ' YOUR TEXT HERE '; % Default to display of 'YOUR TEXT HERE'
end
t = now; % Grab current system time
% Convert it to a datetime format and put that value in a string
d = string(datetime(t,'ConvertFrom','datenum'));
% Time = pad(d,2,'both'); % Pad each end of the string by two spaces
spacer = " "; % Create Spacer string for extra padding
temp = floor(1 + (46-1).*rand(1,1)); % Create random temperature value
% Concatenate all pieces in a string then convert it to a character array
display = char(strcat(spacer,msg,spacer,"Today's Date Is: ",d,spacer,"The Current Temperature Is: ",num2str(temp),char(176),"C"));
% Display the message back to the User on the UIAxes in the Right Panel
ax = app.UIAxes('Parent',app.RightPanel);
ax.Color = bgColor;
ax.Box = 'on';
hold on
for i = 1:(length(display)+1) % Loop once for length of entire message
cla(ax) % Clear previous Axes
ax = gca; % Create axis handle
ax.Color = bgColor; % Set background color of the plot window
text('Parent',ax,display,'Color',txtColor,'FontSize',72,'FontName','LED Counter 7'); % Display message as text
display = circshift(display,-1); % Circle Shift character array, Scrolling Left
i = i + 1; % Increment i
pause(0.5); % Pause for 0.5 sec
end
end
1 Comment
Lucas Lombard
on 1 Dec 2022
Edited: Lucas Lombard
on 1 Dec 2022
Accepted Answer
More Answers (0)
Categories
Find more on Dates and Time 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!

