How to prevent one figure from resizing while another figure continuously updates?

조회 수: 3 (최근 30일)
Tim
Tim 2020년 2월 28일
댓글: Tim 2020년 2월 28일
I have two plots generated by the code below. The first is a hinton weight matrix (deep learning toolbox) and the second is the voltage read from an arduino. When I run the code, the voltage plot works as expected where it displays the last 25 seconds and continues to update.
The problem I'm having is as the voltage plot continues to update, the hinton weight matrix keeps resizing. I'd like to have the hinton weight matrix to open and only update if a value in the matrix changes.
a = arduino;
%-------------------------------------------------------------------------
x = -1*ones(5,5);
figure(1)
hintonw(x)
axis off
axis manual
%-------------------------------------------------------------------------
% Variables
time = 0;
data = 0;
count = 0;
% Set up Plot
figure(2)
plotGraph = plot(time,data,'-r' );
grid on;
tic
while ishandle(plotGraph)
dat = readVoltage(a,'A0');
count = count + 1;
time(count) = toc;
data(count) = dat(1);
set(plotGraph,'XData',time,'YData',data);
ylim([0 3.3])
if time(count) > 20
xlim([(time(count)-20) time(count)])
else
xlim([0 time(count)])
end
pause(0.01);
end
  댓글 수: 2
Tim
Tim 2020년 2월 28일
Thanks a lot! I added these lines and it works well.
fig2 = figure(2);
ax1 = axes('Parent',fig2);
In the while loop:
ylim(ax1,[min max])
if time(count) > 20
xlim(ax1,[(time(count)-20) time(count)])
else
xlim(ax1,[0 time(count)])
end

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Animation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by