Plotting multiple graph on 1 axes GUI
1 回表示 (過去 30 日間)
古いコメントを表示
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
2012 年 7 月 31 日
So you want to plot each new set of data as an additional line on the graph?
回答 (1 件)
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.
参考
カテゴリ
Help Center および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!