📄 ch4.m
字号:
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit20_Callback(hObject, eventdata, handles)
% hObject handle to edit20 (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 edit20 as text
% str2double(get(hObject,'String')) returns contents of edit20 as a double
% --- Executes during object creation, after setting all properties.
function edit20_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit20 (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 edit21_Callback(hObject, eventdata, handles)
% hObject handle to edit21 (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 edit21 as text
% str2double(get(hObject,'String')) returns contents of edit21 as a double
% --- Executes during object creation, after setting all properties.
function edit21_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit21 (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 freqanalyse.
function freqanalyse_Callback(hObject, eventdata, handles)
% hObject handle to freqanalyse (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'));
if handles.inputtype==0
msgbox('No wave exist! Please choose a input type!');
return;
end
from=str2double(get(handles.pointfrom,'String'));
to=str2double(get(handles.pointto,'String'));
sample=handles.y(from:to);
f=linspace(0,Fs/2,(to-from+1)/2);
Y=fft(sample,to-from+1);
[C,I]=max(abs(Y));
set(handles.foutt,'String',1/f(I));
set(handles.foutfreq,'String',f(I));
Y=Y(1:(to-from+1)/2);
plot(handles.plot1,f,2*sqrt(Y.*conj(Y)));
plot(handles.plot2,f,angle(Y));
plot(handles.plot3,f,real(Y));
plot(handles.plot4,f,imag(Y));
plot(handles.plot5,f,abs(Y).^2);
xlabel(handles.plot1,'freqency(Hz)');
xlabel(handles.plot2,'freqency(Hz)');
xlabel(handles.plot3,'freqency(Hz)');
xlabel(handles.plot4,'freqency(Hz)');
xlabel(handles.plot5,'freqency(Hz)');
ylabel(handles.plot1,'amplitude');
ylabel(handles.plot2,'phase(rad)');
ylabel(handles.plot3,'real');
ylabel(handles.plot4,'Imaginary');
ylabel(handles.plot5,'power');
function pointfrom_Callback(hObject, eventdata, handles)
% hObject handle to pointfrom (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 pointfrom as text
% str2double(get(hObject,'String')) returns contents of pointfrom as a double
% --- Executes during object creation, after setting all properties.
function pointfrom_CreateFcn(hObject, eventdata, handles)
% hObject handle to pointfrom (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 pointto_Callback(hObject, eventdata, handles)
% hObject handle to pointto (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 pointto as text
% str2double(get(hObject,'String')) returns contents of pointto as a double
% --- Executes during object creation, after setting all properties.
function pointto_CreateFcn(hObject, eventdata, handles)
% hObject handle to pointto (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 play.
function play_Callback(hObject, eventdata, handles)
% hObject handle to play (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'));
wavplay(handles.y,Fs);
% --- Executes on slider movement.
function scale_Callback(hObject, eventdata, handles)
% hObject handle to scale (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
val=get(hObject,'value');
val=10^(val*5+1);
x=get(handles.xmove,'Value')*str2double(get(handles.samplenum,'String'));
axis(handles.time,[x val+x min(handles.y) max(handles.y)]);
% --- Executes during object creation, after setting all properties.
function scale_CreateFcn(hObject, eventdata, handles)
% hObject handle to scale (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.9 .9 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on slider movement.
function scale2_Callback(hObject, eventdata, handles)
% hObject handle to scale2 (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
val=get(hObject,'value');
val=10^(val*5+1);
xlim(handles.plot1,[0 val]);
xlim(handles.plot2,[0 val]);
xlim(handles.plot3,[0 val]);
xlim(handles.plot4,[0 val]);
% --- Executes during object creation, after setting all properties.
function scale2_CreateFcn(hObject, eventdata, handles)
% hObject handle to scale2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.9 .9 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function channel_Callback(hObject, eventdata, handles)
% hObject handle to channel (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 channel as text
% str2double(get(hObject,'String')) returns contents of channel as a double
% --- Executes during object creation, after setting all properties.
function channel_CreateFcn(hObject, eventdata, handles)
% hObject handle to channel (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 selection change in wavetype.
function wavetype_Callback(hObject, eventdata, handles)
% hObject handle to wavetype (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 wavetype contents as cell array
% contents{get(hObject,'Value')} returns selected item from wavetype
% --- Executes during object creation, after setting all properties.
function wavetype_CreateFcn(hObject, eventdata, handles)
% hObject handle to wavetype (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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on button press in add.
function add_Callback(hObject, eventdata, handles)
% hObject handle to add (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 add
% --- Executes during object deletion, before destroying properties.
function add_DeleteFcn(hObject, eventdata, handles)
% hObject handle to add (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on slider movement.
function xmove_Callback(hObject, eventdata, handles)
% hObject handle to xmove (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
val=get(handles.scale,'value');
val=10^(val*5+1);
x=get(hObject,'Value')*str2double(get(handles.samplenum,'String'));
axis(handles.time,[x val+x min(handles.y) max(handles.y)]);
% --- Executes during object creation, after setting all properties.
function xmove_CreateFcn(hObject, eventdata, handles)
% hObject handle to xmove (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.9 .9 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on button press in analyseall.
function analyseall_Callback(hObject, eventdata, handles)
% hObject handle to analyseall (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if get(hObject,'Value')==0.0
set(handles.pointfrom,'Enable','on');
set(handles.pointto,'Enable','on');
else
set(handles.pointfrom,'String','1','Enable','off');
set(handles.pointto,'String',get(handles.samplenum,'String'),'Enable','off');
end
function outt_Callback(hObject, eventdata, handles)
% hObject handle to outt (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 outt as text
% str2double(get(hObject,'String')) returns contents of outt as a double
% --- Executes during object creation, after setting all properties.
function outt_CreateFcn(hObject, eventdata, handles)
% hObject handle to outt (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 foutt_Callback(hObject, eventdata, handles)
% hObject handle to foutt (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 foutt as text
% str2double(get(hObject,'String')) returns contents of foutt as a double
% --- Executes during object creation, after setting all properties.
function foutt_CreateFcn(hObject, eventdata, handles)
% hObject handle to foutt (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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -