Excel plotting using popup menu
Mostra commenti meno recenti
Hello everyone
i am creating a matlab gui which consist of a pushbutton for importing the excel file and four popup menu buttons each one will select a particular sheet from the loaded excel sheet and another poup menu in which one column of excel sheet will be loaded user will select a particular value and i want those four popup menu buttons should give the particular value from certain column corresponding to value selected from the user in fifth popup menu button then i will use those values for plotting.
i hope that i am clear
code as follows
function varargout = imgplt3d(varargin)
% IMGPLT3D MATLAB code for imgplt3d.fig
% IMGPLT3D, by itself, creates a new IMGPLT3D or raises the existing
% singleton*.
%
% H = IMGPLT3D returns the handle to a new IMGPLT3D or the handle to
% the existing singleton*.
%
% IMGPLT3D('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in IMGPLT3D.M with the given input arguments.
%
% IMGPLT3D('Property','Value',...) creates a new IMGPLT3D or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before imgplt3d_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to imgplt3d_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help imgplt3d
% Last Modified by GUIDE v2.5 27-May-2019 15:22:01
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @imgplt3d_OpeningFcn, ...
'gui_OutputFcn', @imgplt3d_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
% End initialization code - DO NOT EDIT
% --- Executes just before imgplt3d is made visible.
function imgplt3d_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to imgplt3d (see VARARGIN)
% Choose default command line output for imgplt3d
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes imgplt3d wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = imgplt3d_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.filename = uigetfile('*.xls')
guidata(hObject, handles)
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
[~, Sheets1]=xlsfinfo(handles.filename)
set(hObject,'String',Sheets1)
index_selected = get(hObject, 'Value')
sheet_list=get(hObject, 'String')
selectedsheet=sheet_list{index_selected}
filename=handles.filename
handles.data1=xlsread(filename, selectedsheet)
data1=handles.data1
set(hObject, 'data1')
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu2
[~, Sheets2]=xlsfinfo(handles.filename)
set(hObject,'String',Sheets2)
index_selected = get(hObject, 'Value')
sheet_list=get(hObject, 'String')
selectedsheet=sheet_list{index_selected}
filename=handles.filename
handles.data2=xlsread(filename, selectedsheet)
data2=handles.data2
set(hObject, 'data2')
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu3.
function popupmenu3_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu3 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu3
[~, Sheets3]=xlsfinfo(handles.filename)
set(hObject,'String',Sheets3)
index_selected = get(hObject, 'Value')
sheet_list=get(hObject, 'String')
selectedsheet=sheet_list{index_selected}
filename=handles.filename
handles.data3=xlsread(filename, selectedsheet)
data3=handles.data3
set(hObject, 'data3')
% --- Executes during object creation, after setting all properties.
function popupmenu3_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu4.
function popupmenu4_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu4 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu4
[~, Sheets4]=xlsfinfo(handles.filename)
set(hObject,'String',Sheets4)
index_selected = get(hObject, 'Value')
sheet_list=get(hObject, 'String')
selectedsheet=sheet_list{index_selected}
filename=handles.filename
handles.data4=xlsread(filename, selectedsheet)
data4=handles.data4
set(hObject, 'data4')
% --- Executes during object creation, after setting all properties.
function popupmenu4_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu6.
function popupmenu6_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu6 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu6
filename=handles.filename
data5=xlsread(filename, '201', 'T7:T593');
set(hObject,'String', data5);
item_selected=get(hObject, 'Value')
frequency=get(hObject, 'String')
selectedfrequency=frequency(item_selected)
get(handles.popupmenu1, 'data1')
item=data1(item_selected, 29)
% --- Executes during object creation, after setting all properties.
function popupmenu6_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

Risposta accettata
Più risposte (0)
Categorie
Scopri di più su App Building in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!