Simultanously plotting on two figures

1 回表示 (過去 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 Center および File ExchangeGraphics Objects についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by