Why is one of my tiled plots not being displayed? MATLAB UI App Designer

23 views (last 30 days)
Hi there,
I am new to the App Designer and am trying to make an app out of existing code of mine. I have 4 tiled plots in a panel in my UI, where 3 are properly displayed while the 4th is not. The title and axis lables are displayed for the 4th graph but not the curve. In trouble shooting, I have writen a line to display the 4th graph in its own figure window, and it works and is plotted as I expect. I am not sure why I cannot get it to plot in the UI. I have included a screen shot of the graphs as well as my code for this section.
Any help would be appreciated!
%collecting displacement data into single matrix
Cam_Displacement = [Rise_Segment, dwellA, Fall_Segment, dwellB];
%differentiation
%works fine
theta = linspace(0,360,length(Cam_Displacement));
velocity = diff(Cam_Displacement(:))./diff(theta(1:length(theta)-1));
acceleration = diff(velocity)./ diff(theta(1:length(theta)-1));
jerk = diff(acceleration)./diff(theta(1:length(theta)-1));
%prints polar plot to panel in UI
%works fine
p = polaraxes(app.CamProfilePanel);
polarplot(p,Cam_Displacement)
%Plotting SVAJ curves
t = tiledlayout(app.SVAJPlotsPanel,4,1);
%works fine
ax1 = nexttile(t);
plot(ax1,theta,Cam_Displacement,'b')
axis auto;
xlim(ax1,[0 360]);
xlabel(ax1,'Degrees');
ylabel(ax1,'in');
title(ax1,'Displacement');
%works fine
ax2 = nexttile(t);
plot(ax2,theta(1:length(theta)-1),velocity,'r');
axis auto;
xlim(ax2,[0 360]);
title(ax2,'Velocity')
ylabel(ax2,'in/sec')
xlabel(ax2,'Degrees')
%works fine
ax3 = nexttile(t);
plot(ax3,theta(1:length(theta)-2),acceleration,'g');
axis auto;
xlim(ax3,[0 360]);
title(ax3,'Acceleration');
ylabel(ax3,'in/sec^2');
xlabel(ax3,'Degrees');
%this is the plot that I am not getting to show up
ax4 = nexttile(t);
plot(theta(1:length(theta)-3),jerk,'c')
axis auto;
xlim(ax4,[0 360]);
title(ax4,'Jerk')
ylabel(ax4,'in/sec^3')
xlabel(ax4,'Degrees')
%this is the validation plot which shows up correctly in its own figure
figure(1)
plot(jerk)
Here are the images of what my program is outputting. As you can see there is no curve in the jerk plot:
This is my standalone plot which is working as expected:
Perhapse this is a very simple mistake and I am just missing something in my code. Thanks again.

Accepted Answer

Adam Danz
Adam Danz on 20 Jan 2021
plot(ax4,theta(1:length(theta)-3),jerk,'c')
% ^^^ you forgot this part

More Answers (1)

Kyle McLaughlin
Kyle McLaughlin on 20 Jan 2021
Im sorry to have posted this and made people look at it, I figured out my issue. I am missing 'ax4' when I call the plot function for that particular graph. Not sure if I just delete this or not now, but what I can say is it pays to get up and walk away then come back to code after a half hour or so!
Addendum:
%this is the plot that I am not getting to show up
ax4 = nexttile(t);
%adding in ax4 before theta fixes it
plot(ax4,theta(1:length(theta)-3),jerk,'c')
axis auto;
xlim(ax4,[0 360]);
title(ax4,'Jerk')
ylabel(ax4,'in/sec^3')
xlabel(ax4,'Degrees')

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!