⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 juanji.m

📁 这个是我数字信号处理这门课的课程设计,文件包括用matlab编写的代码和设计报告.这个设计包括卷积演示程序、采样定理演示程序、模拟滤波器设计演示程序、设计切比雪夫I型低通滤波器、切比雪夫I型低通滤波器
💻 M
字号:
function varargout = juanji(varargin)
% JUANJI M-file for juanji.fig
%      JUANJI, by itself, creates a new JUANJI or raises the existing
%      singleton*.
%
%      H = JUANJI returns the handle to a new JUANJI or the handle to
%      the existing singleton*.
%
%      JUANJI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in JUANJI.M with the given input arguments.
%
%      JUANJI('Property','Value',...) creates a new JUANJI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before juanji_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to juanji_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 juanji

% Last Modified by GUIDE v2.5 07-Jan-2006 22:36:15

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @juanji_OpeningFcn, ...
                   'gui_OutputFcn',  @juanji_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 juanji is made visible.
function juanji_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 juanji (see VARARGIN)

% Choose default command line output for juanji
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes juanji wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = juanji_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;



function x1_Callback(hObject, eventdata, handles)
% hObject    handle to x1 (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 x1 as text
%        str2double(get(hObject,'String')) returns contents of x1 as a double


% --- Executes during object creation, after setting all properties.
function x1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to x1 (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 x2_Callback(hObject, eventdata, handles)
% hObject    handle to x2 (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 x2 as text
%        str2double(get(hObject,'String')) returns contents of x2 as a double


% --- Executes during object creation, after setting all properties.
function x2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to x2 (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 N_Callback(hObject, eventdata, handles)
% hObject    handle to N (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 N as text
%        str2double(get(hObject,'String')) returns contents of N as a double
N=findobj('Tag','N');
strN=get(N,'String');
strN=str2num(strN);

% --- Executes during object creation, after setting all properties.
function N_CreateFcn(hObject, eventdata, handles)
% hObject    handle to N (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 juanji1.
function juanji1_Callback(hObject, eventdata, handles)
% hObject    handle to juanji1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
x1=findobj('Tag','x1');
str1=get(x1,'String');
u=str2num(str1);
x2=findobj('Tag','x2');
str2=get(x2,'String');
h=str2num(str2);

lu=length(u);
lh=length(h);                 % 确定序列长度
lmax=max(lu,lh);
if lu>lh nu=0;nh=lu-lh;			% 若u比h长,对h补nh个零
elseif lu<lh nh=0;nu=lh-lu;		% 若h比u长,对u补nu个零
else nu=0;nh=0;					% 若h与u同长,不补零
end

lt=lmax;						% 取长者为补零长度基准
u=[zeros(1,lt),u,zeros(1,nu),zeros(1,lt)];	% 将u先补得与h同长,再两边补以同长度的零
t1=(-lt+1:2*lt);
h=[zeros(1,2*lt),h,zeros(1,nh)];		% 将h先补得与u同长,再两边补以同长度的零
hf=fliplr(h);					% 将h的左右翻转,称为hf
y=zeros(1,3*lt);
for k=0:2*lt
   p=[zeros(1,k),hf(1:end-k)];		% 使hf向右循环移位
   y1=u.*p;					% 使输入和翻转移位的脉冲过渡函数逐项相乘
   yk=sum(y1);					% 相加,相当于积分
   y(k+lt+1)=yk;					% 将结果放入数组y
   % 绘图,注意如何用axis命令把各子图的横坐标统一起来,使纵坐标随数据自动调整
   a=findobj('Tag','axes1');

   stem(t1,u,'.');		         % 用stem是为了避免plot函数在突跳点形成的斜边
   axis([-lt,2*lt,min(u),max(u)]),hold on  %绘制u(n)序列图
   ylabel('u(n)序列图')
   b=findobj('Tag','axes2');
   
   stem(t1,p,'.');        % 绘制p(即h(k-n))序列的样本图
   axis([-lt,2*lt,min(p),max(p)])
   ylabel('h(k-n)序列图')
   c=findobj('Tag','axes3');
  
   stem(t1,y1,'.')       % 绘制y1序列的样本图
   axis([-lt,2*lt,min(y1),max(y1)+eps])
   ylabel('s=u.*h(k-n)')
   d=findobj('Tag','axes4');
 
   stem(k,yk,'.');	    % 用stem函数表示每一次卷积积分求和的结果	
   axis([-lt,2*lt,floor(min(y)+eps),ceil(max(y+eps))]),hold on
   ylabel('y(k)=sum(s)')
  pause(0.2)
end

% --- Executes on button press in yuanzhou2.
function yuanzhou2_Callback(hObject, eventdata, handles)
% hObject    handle to yuanzhou2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -