www.gusucode.com > Matlab动力系统和时间序列分析工具箱 > Matlab动力系统和时间序列分析工具箱/lab432/gui/gui_select_time_int.m

    function varargout = gui_select_time_int(varargin)
% GUI_SELECT_TIME_INT extract subset of data according to selected time interval
%
% Last Modified by GUIDE v2.5 04-Oct-2003 10:25:11
% last modified 07.12.04

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @gui_select_time_int_OpeningFcn, ...
                   'gui_OutputFcn',  @gui_select_time_int_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(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 gui_select_time_int is made visible.
function gui_select_time_int_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 gui_select_time_int (see VARARGIN)

global TS GSD_GLOBALS 
% Choose default command line output for gui_select_time_int
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes gui_select_time_int wait for user response (see UIRESUME)
% uiwait(handles.figure1);
GSD_GLOBALS.advanced_fig_handles=[GSD_GLOBALS.advanced_fig_handles hObject];

plot(TS.time,TS.data(:,1))
title(TS.name{1},'interpreter','none');
set(handles.edit_t_min,'string',num2str(min(TS.time)));
set(handles.edit_t_max,'string',num2str(max(TS.time)));

    

% --- Outputs from this function are returned to the command line.
function varargout = gui_select_time_int_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
if ~isempty(handles)
    varargout{1} = handles.output;
end


% --- Executes during object creation, after setting all properties.
function popup_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popup (see GCBO)
% handles    empty - handles not created until after all CreateFcns called

global TS
% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

set(hObject,'string',TS.name);


% --- Executes on selection change in popup.
function popup_Callback(hObject, eventdata, handles)
% hObject    handle to popup (see GCBO)
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popup contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popup
global TS
selection=get(hObject,'Value');
plot(TS.time,TS.data(:,selection))
title(TS.name{selection},'interpreter','none');
edit_t_min_Callback(handles.edit_t_min, [], handles);



% --- Executes during object creation, after setting all properties.
function edit_t_min_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_t_min (see GCBO)
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function edit_t_min_Callback(hObject, eventdata, handles)
% hObject    handle to edit_t_min (see GCBO)
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_t_min as text
%        str2double(get(hObject,'String')) returns contents of edit_t_min as a double
global TS

%time_range=[min(GSD.crd.time) max(GSD.crd.time)];
e_t_min=str2num(get(handles.edit_t_min,'string'));
e_t_max=str2num(get(handles.edit_t_max,'string'));
selection=get(handles.popup,'value');

TIME=TS.time;
Tmin=find(TIME>=e_t_min);
Tmin=Tmin(1);
Tmax=find(TIME<=e_t_max);
Tmax=Tmax(end);

set(handles.edit_t_min,'string',num2str(TIME(Tmin)));
set(handles.edit_t_max,'string',num2str(TIME(Tmax)));
set(handles.axes1,'xlim',[TIME(Tmin) TIME(Tmax)]);



% --- Executes during object creation, after setting all properties.
function edit_t_max_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_t_max (see GCBO)
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on button press in cancel.
function cancel_Callback(hObject, eventdata, handles)
% hObject    handle to cancel (see GCBO)
% handles    structure with handles and user data (see GUIDATA)
close(handles.figure1);

% --- Executes on button press in ok.
function ok_Callback(hObject, eventdata, handles)
% hObject    handle to ok (see GCBO)
% handles    structure with handles and user data (see GUIDATA)

global TS

selection=get(handles.popup,'value');
TIME=TS.time;

t_min=str2num(get(handles.edit_t_min,'string'));
t_max=str2num(get(handles.edit_t_max,'string'));
Tmin_ix=find(TIME>=t_min);
Tmax_ix=find(TIME<=t_max);
Tmin_ix=min(Tmin_ix);
Tmax_ix=max(Tmax_ix);

TS.time=TIME(Tmin_ix:Tmax_ix);
TS.data=TS.data(Tmin_ix:Tmax_ix,:);

close(handles.figure1);