Plotting multiple graph on 1 axes GUI

조회 수: 2 (최근 30일)
Dzhamshed
Dzhamshed 2012년 7월 31일
Hello to everyone, I have got an *.xlsx database, which refreshes each 20 sec and add some rows of data. I need to make a GUI to make some temp-time graph, with an ability of making multiple graphs on one axes. How can I do this? I don'tknow anything about MATLab, I tried like here http://blogs.mathworks.com/videos/2007/08/13/video-series-reading-excel-data-into-matlab-with-a-gui/. But by the help of this it can plot just 1 graph, but there are N arrays of values for y-axis, and just 1 for x. Please, help me if you are able. here is the code
function varargout = mainGUI(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @mainGUI_OpeningFcn, ...
'gui_OutputFcn', @mainGUI_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function mainGUI_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = mainGUI_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function pushbuttonLoadXLS_Callback(hObject, eventdata, handles)
handles.fileName=uigetfile('*.xls')
guidata(hObject, handles)
setPopupmenuString(handles.popupmenuX, eventdata, handles)
setPopupmenuString(handles.popupmenuY, eventdata, handles)
set (handles. popupmenuX, 'callback','mainGUI(''updateAxes'',gcbo,[],guidata(gcbo))')
set (handles. popupmenuY, 'callback','mainGUI(''updateAxes'',gcbo,[],guidata(gcbo))')
function setPopupmenuString(hObject, eventdata, handles)
fileName=handles.fileName;
[numbers,colNames]=xlsread(fileName);
set(hObject,'string',colNames);
function [x,y] = readExcelColumns (fileName, xColNum, yColNum)
a= xlsread(fileName);
x=a(:,xColNum);
y=a(:,yColNum)
function updateAxes (hObject, eventdata, handles)
xColNum = get(handles.popupmenuX, 'value');
yColNum = get(handles.popupmenuY, 'value');
fileName=handles.fileName;
[x,y] = readExcelColumns (fileName, xColNum, yColNum)
plot (handles.axes1,x,y)
function popupmenuY_Callback(hObject, eventdata, handles)
function popupmenuY_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function popupmenuX_Callback(hObject, eventdata, handles)
function popupmenuX_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
  댓글 수: 2
Sean de Wolski
Sean de Wolski 2012년 7월 31일
So you want to plot each new set of data as an additional line on the graph?
Dzhamshed
Dzhamshed 2012년 7월 31일
Not new set of data, for example there are 8 columns with various temperature values. I want a possibility to choose, which columns are need for the graph, maybe is I choose 4 of them, there must be 4 resultant lines on the coordinate plane, and so on.

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

답변 (1개)

Sean de Wolski
Sean de Wolski 2012년 7월 31일
Use plot() to plot four lines. Consider the following:
x = rand(8,10);
plot(x(:,[1 3 5 8])) %plot the first third fifth and eighth columns of x.
  댓글 수: 1
Dzhamshed
Dzhamshed 2012년 7월 31일
Can you show me on my code? Just I don't know anything about MatLAB

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

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by