Simultanously plotting on two figures

2 visualizaciones (últimos 30 días)
Dominik Maly
Dominik Maly el 7 de Dic. de 2019
Respondida: Roshni Garnayak el 13 de Dic. de 2019
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 comentarios
Dominik Maly
Dominik Maly el 8 de Dic. de 2019
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 el 8 de Dic. de 2019
Yes? Detect the button press and draw or update both plots.

Iniciar sesión para comentar.

Respuestas (1)

Roshni Garnayak
Roshni Garnayak el 13 de Dic. de 2019
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.

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by