Simultanously plotting on two figures

조회 수: 2 (최근 30일)
Dominik Maly
Dominik Maly 2019년 12월 7일
답변: Roshni Garnayak 2019년 12월 13일
Hey i've got problem.
In my GUI, i've got some buttons. On btn1 press figure is being created and plotting stars.
Here's my problem. I want to make on this press 2 figures with 2 simultanous plot. Or at least make a subplots on one figure.
How can I do it?
Here's my code for one plot:
if handles.StartbtnVal
%Sprawdzanie guidata co jakis czas POPR
guidata(figureHandle, handles)
if j==0
fprintf(s,'%c',znak);
plotFigure = figure(2);
axesHandle=axes();
plotHandle=plot(axesHandle,NaN,NaN);
% plotFigureHandle=plot(axesHandle,NaN,NaN);
axis([0 1000 -Inf Inf])
drawnow
else
end
if k==0;
set(h.Editfield4,'String','Rysowanie');
k=1;
else
end
zm1=fgetl(s); %Pobranie aktualnej wartości z bufora
j=j+1; %Iterator w prowadzony w celu odpowiedniego nawigowania pozycji w macierzy
zm2=strip(zm1); %Polecenie usuwające wszelkie dotyczące znaku zakończenia bądź początku linii
zm3=str2double(zm2); %Zamiana otrzymanej wartości z znakowej na liczbową
DataBuff(1,j)=zm3; %Utworzenie wektora wartości otrzymanych z układu
DrawBuff(1,j)=DataBuff(1,j);
xfilt(1,j)=j;
% figure(2)
set(plotHandle,'YData',DrawBuff,'XData',x);
% if mod(j,200) == 0
% yfilt=filtfilt(1,1,DataBuff);
% set(plotFigureHandle,'YData',DrawBuff,'XData',x);
% drawnow
% else
% end
drawnow
  댓글 수: 3
Dominik Maly
Dominik Maly 2019년 12월 8일
I want to do it in my while loop, obly detect the button push and I've done it. Now i've got problem with this plot.
Walter Roberson
Walter Roberson 2019년 12월 8일
Yes? Detect the button press and draw or update both plots.

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

답변 (1개)

Roshni Garnayak
Roshni Garnayak 2019년 12월 13일
You can specify two different handles for the two axes and while plotting specify the handle of the axis you want to plot on. The following command creates handles for the subplots:
Ax1 = subplot(1, 2, 1);
Ax2 = subplot(1, 2, 2);
To check the documentation for ‘subplot’ refer to the following link:
Implement the logic for plotting inside the callback function for the button.

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by