Plotting inside a loop - reset axes values

Please see pic. I can't get the default values for he secondary axes to go away. They persistently stay on the plot
% Create figure
figure1 = figure;
x0=0;
y0=0;
width=24;
height=14;
set(figure1,'units','inch','position',[x0,y0,width,height]);
tStep = 5*0.05
for i = 1:1:100
L = W;
Y = Data(i,:,1);
X = Data(i,:,2);
St = Data(i,1,3);
index = round(St/0.05);
L(index) = 100;
L(index+5) = 100;
% Create axes
axes1 = axes('Parent',figure1,...
'Position',[0.0578034682080925 0.631751227495908 0.922928709055877 0.320785597381343]);
hold(axes1,'on');
% Create plot
plot(t,v,'Parent',axes1,'LineWidth',1.5);
% Create plot
plot([St,St],[80,-20],'Parent',axes1,'LineWidth',1.5,'Color',[1 0 0]);
% Create plot
plot([St + tStep,St + tStep],[80,-20],'Parent',axes1,'LineWidth',1.5,'Color',[1 0 0]);
hold(axes1,'off');
% Create ylabel
ylabel({'Voltage',''});
% Create xlabel
xlabel('Time');
% Create title
title('Desired Response');
% Uncomment the following line to preserve the X-limits of the axes
xlim(axes1,[7 35]);
box(axes1,'on');
% Create axes
axes2 = axes('Parent',figure1,...
'Position',[0.0606936416184971 0.08 0.917148362235067 0.43],'nextplot','replaceall');
% Create plot
plot(X,Y,'Parent',axes2,'LineWidth',1,...
'Color',[1 0 0]);
% Create ylabel
ylabel({'Error',''});
% Create xlabel
xlabel('Amplitude');
% Create title
title('Error Sensitivity');
box(axes2,'on');
xlim(axes2,[0 4.9]);
pause(1.5);
cla(axes2,'reset');

3 个评论

Note that you are not parenting your *label() and title() calls.
If you do not want those labels, then why not set the axes xtick and ytick to [] ?
I want the labels there. If you look closely at the picture there are two sets of numbers. I only want one set.
Unfortunately we do not have the values of some of your variables to test with. I do not see anything obvious

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Animation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by