📄 ch4.m
字号:
function recordtime_Callback(hObject, eventdata, handles)
% hObject handle to recordtime (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 recordtime as text
% str2double(get(hObject,'String')) returns contents of recordtime as a double
% --- Executes during object creation, after setting all properties.
function recordtime_CreateFcn(hObject, eventdata, handles)
% hObject handle to recordtime (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 startrecord.
function startrecord_Callback(hObject, eventdata, handles)
% hObject handle to startrecord (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Fs=str2double(get(findobj('Tag','samplerate'),'String'));
handles.y=wavrecord(str2double(get(findobj('Tag','recordtime'),'String'))*Fs, Fs,'int16');
handles.inputtype=1;
guidata(hObject,handles);
plot(handles.time,handles.y);
title('WAVE');
ysize=size(handles.y)
set(handles.samplenum,'String',num2str(ysize(1)));
% --- Executes on button press in fileopen.
function fileopen_Callback(hObject, eventdata, handles)
% hObject handle to fileopen (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
temp = wavread(get(findobj('Tag','filename'),'String'));
channel=str2double(get(handles.channel,'String'));
handles.y=temp(:,channel);
handles.inputtype=2;
guidata(hObject,handles);
plot(handles.time,handles.y);
title('WAVE');
ysize=size(handles.y)
set(handles.samplenum,'String',num2str(ysize(1)));
% --- Executes on button press in gensig.
function gensig_Callback(hObject, eventdata, handles)
% hObject handle to gensig (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Fs=str2double(get(findobj('Tag','samplerate'),'String'));
N=str2double(get(findobj('Tag','samplenum'),'String'));
x=linspace(0,N/Fs,N);
soundtype=get(handles.wavetype,'Value');
frequency=str2double(get(handles.freq,'String'));
amp=str2double(get(handles.amp,'String'));
phase=str2double(get(handles.phase,'String'));
switch soundtype
case 1
y=amp*sin(2*pi*x*frequency+phase);
case 2
y=amp*sign(sin(2*pi*x*frequency+phase));
case 3
y=amp*sawtooth(2*pi*x*frequency+phase,0.5);
case 4
y=amp*sawtooth(2*pi*x*frequency+phase);
case 5
y=amp*(2*rand(size(x))-1);
otherwise
errordlg('Illegal wave type','Choose errer');
end
if get(handles.add,'Value')==0.0
handles.y=y;
else
handles.y=handles.y+y;
end
handles.inputtype=3;
guidata(hObject,handles);
plot(handles.time,handles.y);
title('WAVE');
axis([0 N -str2double(get(handles.amp,'String')) str2double(get(handles.amp,'String'))]);
function outfreq_Callback(hObject, eventdata, handles)
% hObject handle to outfreq (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 outfreq as text
% str2double(get(hObject,'String')) returns contents of outfreq as a double
% --- Executes during object creation, after setting all properties.
function outfreq_CreateFcn(hObject, eventdata, handles)
% hObject handle to outfreq (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 outamp_Callback(hObject, eventdata, handles)
% hObject handle to outamp (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 outamp as text
% str2double(get(hObject,'String')) returns contents of outamp as a double
% --- Executes during object creation, after setting all properties.
function outamp_CreateFcn(hObject, eventdata, handles)
% hObject handle to outamp (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 outphase_Callback(hObject, eventdata, handles)
% hObject handle to outphase (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 outphase as text
% str2double(get(hObject,'String')) returns contents of outphase as a double
% --- Executes during object creation, after setting all properties.
function outphase_CreateFcn(hObject, eventdata, handles)
% hObject handle to outphase (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 outpeak_Callback(hObject, eventdata, handles)
% hObject handle to outpeak (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 outpeak as text
% str2double(get(hObject,'String')) returns contents of outpeak as a double
% --- Executes during object creation, after setting all properties.
function outpeak_CreateFcn(hObject, eventdata, handles)
% hObject handle to outpeak (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 outmean_Callback(hObject, eventdata, handles)
% hObject handle to outmean (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 outmean as text
% str2double(get(hObject,'String')) returns contents of outmean as a double
% --- Executes during object creation, after setting all properties.
function outmean_CreateFcn(hObject, eventdata, handles)
% hObject handle to outmean (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 outmeansquare_Callback(hObject, eventdata, handles)
% hObject handle to outmeansquare (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 outmeansquare as text
% str2double(get(hObject,'String')) returns contents of outmeansquare as a double
% --- Executes during object creation, after setting all properties.
function outmeansquare_CreateFcn(hObject, eventdata, handles)
% hObject handle to outmeansquare (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 outs_Callback(hObject, eventdata, handles)
% hObject handle to outs (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 outs as text
% str2double(get(hObject,'String')) returns contents of outs as a double
% --- Executes during object creation, after setting all properties.
function outs_CreateFcn(hObject, eventdata, handles)
% hObject handle to outs (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 foutfreq_Callback(hObject, eventdata, handles)
% hObject handle to foutfreq (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 foutfreq as text
% str2double(get(hObject,'String')) returns contents of foutfreq as a double
% --- Executes during object creation, after setting all properties.
function foutfreq_CreateFcn(hObject, eventdata, handles)
% hObject handle to foutfreq (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 foutamp_Callback(hObject, eventdata, handles)
% hObject handle to foutamp (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 foutamp as text
% str2double(get(hObject,'String')) returns contents of foutamp as a double
% --- Executes during object creation, after setting all properties.
function foutamp_CreateFcn(hObject, eventdata, handles)
% hObject handle to foutamp (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 foutphase_Callback(hObject, eventdata, handles)
% hObject handle to foutphase (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 foutphase as text
% str2double(get(hObject,'String')) returns contents of foutphase as a double
% --- Executes during object creation, after setting all properties.
function foutphase_CreateFcn(hObject, eventdata, handles)
% hObject handle to foutphase (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 edit18_Callback(hObject, eventdata, handles)
% hObject handle to edit18 (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 edit18 as text
% str2double(get(hObject,'String')) returns contents of edit18 as a double
% --- Executes during object creation, after setting all properties.
function edit18_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit18 (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 edit19_Callback(hObject, eventdata, handles)
% hObject handle to edit19 (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 edit19 as text
% str2double(get(hObject,'String')) returns contents of edit19 as a double
% --- Executes during object creation, after setting all properties.
function edit19_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit19 (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.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -