📄 ss.m
字号:
function varargout = SS(varargin)
% SS M-file for SS.fig
% SS, by itself, creates a new SS or raises the existing
% singleton*.
%
% H = SS returns the handle to a new SS or the handle to
% the existing singleton*.
%
% SS('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SS.M with the given input arguments.
%
% SS('Property','Value',...) creates a new SS or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before SS_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to SS_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
% Edit the above text to modify the response to help SS
% Last Modified by GUIDE v2.5 15-Apr-2006 12:43:28
% Begin initialization code - DO NOT EDIT1
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @SS_OpeningFcn, ...
'gui_OutputFcn', @SS_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 EDIT1
% --- Executes just before SS is made visible.
function SS_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 SS (see VARARGIN)
% Choose default command line output for SS
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes SS wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = SS_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 selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (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 popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (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 ppfx.
function ppfx_Callback(hObject, eventdata, handles)
fs = str2double(get(handles.edit2,'string'))
f = str2double(get(handles.edit1,'String'))
N = str2double(get(handles.edit3,'string'))
val1 = get(handles.popupmenu1,'Value');
x = 0:(N-1);
f1=x*fs/N;
switch val1
case 1
%x = -(N-1)/2:(N-1)/2;
y1 = sin(2*pi*f*x/fs);
case 2
%x = -(N-1)/2:(N-1)/2;
y1 = square(f*x/fs);
case 3
%x = -(N-1)/2:(N-1)/2;
y1 = sawtooth(f*x/fs);
case 4
%x = -(N-1)/2:(N-1)/2;
y1 = diric(f*pi*x/fs,5);
case 5
%x = [-N:N-1];
y1 = sinc(f*pi*x/fs);
otherwise
y1 = 0;
end
axes(handles.axes7) % Select the proper axes
plot(x/fs,y1,'-g')
axis([0 N/fs -1 1]);
%set(handles.axes1,'XMinorTick','on')
title('时域连续波形');
grid on
axes(handles.axes1) % Select the proper axes
stem(x/fs,y1,'-r.')
axis([0 N*1.0/fs -1 1]);
%set(handles.axes1,'XMinorTick','on')
title('时域离散波形');
grid on
y =fft(y1,N);
mag = abs(y);
axes(handles.axes3) % Select the proper axes
stem(f1,mag,'-b.')
axis([0 fs/2 0 max(mag)]);
%set(handles.axes3,'XMinorTick','on')
title('频域波形');
grid on
% hObject handle to ppfx (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes during object creation, after setting all properties.
function ppfx_CreateFcn(hObject, eventdata, handles)
% hObject handle to ppfx (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (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 edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (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 edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in exit.
function exit_Callback(hObject, eventdata, handles)
close
FirstP1
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (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 edit3 as text
% str2double(get(hObject,'String')) returns contents of edit3 as a double
% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -