?? dataimport.m
字號:
function varargout = DataImport(varargin)
% DATAIMPORT M-file for DataImport.fig
% DATAIMPORT, by itself, creates a new DATAIMPORT or raises the existing
% singleton*.
%
% H = DATAIMPORT returns the handle to a new DATAIMPORT or the handle to
% the existing singleton*.
%
% DATAIMPORT('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DATAIMPORT.M with the given input arguments.
%
% DATAIMPORT('Property','Value',...) creates a new DATAIMPORT or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before DataImport_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to DataImport_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
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help DataImport
% Last Modified by GUIDE v2.5 27-May-2005 21:19:44
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @DataImport_OpeningFcn, ...
'gui_OutputFcn', @DataImport_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 DataImport is made visible.
function DataImport_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 DataImport (see VARARGIN)
% Choose default command line output for DataImport
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes DataImport wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% set(hObject,'OuterPosition',[116.6 8.6923 81 21.1538]);
% --- Outputs from this function are returned to the command line.
function varargout = DataImport_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 checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
% hObject handle to checkbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of checkbox1
% --- Executes on button press in checkboxSet.
function checkboxSet_Callback(hObject, eventdata, handles)
% hObject handle to checkboxSet (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of checkboxSet
if get(hObject,'Value')==1
set([handles.radiobuttonSet2050,handles.radiobuttonSet1580,handles.radiobuttonSet1880],...
'Enable','on');
set(handles.checkboxDate,'Value',0);
set([handles.popupmenuDate,handles.btnDate],'Enable','off');
elseif get(hObject,'Value')==0
set([handles.radiobuttonSet2050,handles.radiobuttonSet1580,handles.radiobuttonSet1880],...
'Enable','off');
set(handles.checkboxDate,'Value',1);
set([handles.popupmenuDate,handles.btnDate],'Enable','on');
end
% --- Executes on button press in radiobuttonSet2050.
function radiobuttonSet2050_Callback(hObject, eventdata, handles)
% hObject handle to radiobuttonSet2050 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobuttonSet2050
% --- Executes on button press in radiobuttonSet1580.
function radiobuttonSet1580_Callback(hObject, eventdata, handles)
% hObject handle to radiobuttonSet1580 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobuttonSet1580
% --- Executes on button press in radiobuttonSet1880.
function radiobuttonSet1880_Callback(hObject, eventdata, handles)
% hObject handle to radiobuttonSet1880 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobuttonSet1880
% --- Executes on button press in checkboxDate.
function checkboxDate_Callback(hObject, eventdata, handles)
% hObject handle to checkboxDate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of checkboxDate
if get(hObject,'Value')==1
set([handles.radiobuttonSet2050,handles.radiobuttonSet1580,handles.radiobuttonSet1880],...
'Enable','off');
set(handles.checkboxSet,'Value',0);
set([handles.popupmenuDate,handles.btnDate],'Enable','on');
elseif get(hObject,'Value')==0
set([handles.radiobuttonSet2050,handles.radiobuttonSet1580,handles.radiobuttonSet1880],...
'Enable','on');
set(handles.checkboxSet,'Value',1);
set([handles.popupmenuDate,handles.btnDate],'Enable','off');
end
% --- Executes on selection change in popupmenuDate.
function popupmenuDate_Callback(hObject, eventdata, handles)
% hObject handle to popupmenuDate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns popupmenuDate contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenuDate
% --- Executes during object creation, after setting all properties.
function popupmenuDate_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenuDate (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 button press in btnDate.
function btnDate_Callback(hObject, eventdata, handles)
% hObject handle to btnDate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
f = figure('Menu','none','Toolbar','none','NumberTitle','off','Name','雙擊選擇日期','position', [378 328 300 300]);
cal = actxcontrol('mscal.calendar', [0 0 300 300], f,{'DblClick' 'my2click'});
handles.cal=cal;
guidata(hObject,handles)
function my2click(varargin)
cal=handles.cal
DateStr=cal.Value
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% save current path
path_pwd=pwd;
set(findobj('name','熱軋溫度仿真工具'),'Userdata',[]);
if get(handles.checkboxSet,'Value')==1
% 如果按 機組 選擇數據
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 判斷機組的選擇,并進入各自的目錄
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if get(handles.radiobuttonSet2050,'Value')==1
path=strcat(pwd,'\data\2050\');
end
if get(handles.radiobuttonSet1580,'Value')==1
path=strcat(pwd,'\data\1580\');
end
if get(handles.radiobuttonSet1880,'Value')==1
path=strcat(pwd,'\data\1880\');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 切換到相應的目錄
cd(path);
% Import data
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[fname,pname]=uigetfile('*.xls','選擇帶鋼數據');%打開文件對話框
if isequal(fname,0)
disp('取消選擇帶鋼')
else
disp(['導入帶鋼數據 ', fullfile(pname, fname)])
n = 100;
progressbar % Create figure and set starting time
for i = 1:n
pause(0.01) % Do something important
progressbar(i/n) % Update figure
end
filename=[pname,fname]; %合并文件路徑和文件名
[btnStripImport.DataImport btnStripImport.VarName]=xlsread(filename);%讀取文件內容
btnStripImport.FileName=fname;
btnStripImport.PathName=pname;
% 將數據存入主界面的Userdate屬性
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
set(findobj('name','熱軋溫度仿真工具'),'Userdata',btnStripImport);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
close;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif get(handles.checkboxDate,'Value')==1
% 如果按 日期 選擇數據
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end
% back to default path
cd(path_pwd);
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close;
% get(gcf,'position')
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -