Simultanously plotting on two figures

2 次查看(过去 30 天)
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.

请先登录,再进行评论。

回答(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