Simultanously plotting on two figures
조회 수: 1 (최근 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
답변 (1개)
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.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!