function varargout = sigany(varargin)
% SIGANY M-file for sigany.fig
% SIGANY, by itself, creates a new SIGANY or raises the existing
% singleton*.
%
% H = SIGANY returns the handle to a new SIGANY or the handle to
% the existing singleton*.
%
% SIGANY('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SIGANY.M with the given input arguments.
%
% SIGANY('Property','Value',...) creates a new SIGANY or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before sigany_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to sigany_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 sigany
% Last Modified by GUIDE v2.5 14-May-2008 18:52:43
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @sigany_OpeningFcn, ...
'gui_OutputFcn', @sigany_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 sigany is made visible.
function sigany_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 sigany (see VARARGIN)
hstartshow=figure;
imshow('start.jpg');
pause(3);
% Choose default command line output for sigany
handles.output = hObject;
handles.time=str2double(get(handles.time,'String')); % 迄㊣
handles.sample=str2double(get(handles.sample,'String')); % 迄
handles.filename=get(handles.name,'String'); % ㊣
axes(handles.axes1); %
set(gcf,'doublebuffer','on') %Reduce plot flicker
P = plot(zeros(1000,1)); % 迆
xlabel('Samples'), axis([0 1000 -1 1]), grid on
title('粒欴杅擂妗奀疏倛');
handles.P=P; % ㊣㊣迆
handles.data=[]; % 車
AI = analoginput('winsound'); % 迄“豕㊣
addchannel(AI,1); % 赤迄
handles.AI=AI; % ㊣迄“豕㊣
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes sigany wait for user response (see UIRESUME)
% uiwait(handles.figure1);
close(hstartshow);
% --- Outputs from this function are returned to the command line.
function varargout = sigany_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 start.
function start_Callback(hObject, eventdata, handles)
% hObject handle to start (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% AI = analoginput('winsound');
% addchannel(AI,1);
AI=handles.AI;
duration = handles.time; % 豕迄㊣
AI.SampleRate=handles.sample; % 豕迄
ActualRate = get(AI,'SampleRate'); % 迄
set(AI,'SamplesPerTrigger',duration*ActualRate) % 豕﹞迄
handles.AI=AI; % ㊣迄“豕㊣豕
guidata(hObject, handles);
P=handles.P; % ㊣迆
start(AI) %
i = 1;
while AI.SamplesAcquired < AI.SamplesPerTrigger % 1000迄邦
if strcmp(AI.Running, 'On') % ‾stop辰﹞
while AI.SamplesAcquired < 1000*i
end
data = peekdata(AI,1000);
set(P,'ydata',data);
drawnow
i = i + 1;
else
break;
end
end
[handles.data handles.t] = getdata(AI,AI.SamplesAcquired); %㊣迄角㊣
% handles.AI=AI;
% length(handles.data)
guidata(hObject, handles);
stop(AI); % 迄
function time_Callback(hObject, eventdata, handles)
% hObject handle to time (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of time as text
% str2double(get(hObject,'String')) returns contents of time as a double
handles.time=str2double(get(hObject,'String')); % 迄㊣
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function time_CreateFcn(hObject, eventdata, handles)
% hObject handle to time (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% 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 sample_Callback(hObject, eventdata, handles)
% hObject handle to sample (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of sample as text
% str2double(get(hObject,'String')) returns contents of sample as a double
handles.sample=str2double(get(hObject,'String')); % 迄
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function sample_CreateFcn(hObject, eventdata, handles)
% hObject handle to sample (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% 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 stop.
function stop_Callback(hObject, eventdata, handles)
% hObject handle to stop (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% wavwrite(handles.data,'mywav.wav');
AI=handles.AI;
stop(A