Plot 2 graph in GUI in a axes

조회 수: 5 (최근 30일)
le nguyen
le nguyen 2019년 6월 1일
댓글: dpb 2019년 6월 1일
Hi everyone,
I'm creating a Matlab guide and trying to creat an axes and 2 push button. First, I want to press pushbutton9, a graph will appear, then I press the pushbutton10, i want the second graph will also appear on the axes when the first is still here to compare 2 graph. I'm using the 'hold on' function but whenever I press the pushbutton 10, the first graph disappears. Can anyone help me so this problem?
Thank you so much.
% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
dataset = xlsread('data.xlsx','Sheet1','A1:B450');
oil = dataset(:,1)
day = dataset(:,2)
plot(handles.axes1,day,oil)
hold on
% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
data = xlsread('data.xlsx','Sheet1','A2:H450');
day = data(:,2);
oil = data(:,8);
plot(handles.axes1,day, oil,'r')
  댓글 수: 1
dpb
dpb 2019년 6월 1일
Try
  1. hold(handles.axes1,'on') in PB10 code...
  2. Use low-level |line() instead of plot in PB10...

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by