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

📄 convp.m

📁 很多matlab的源代码
💻 M
字号:
function Y = convp(x,y,dt,ty)
% CONVP Periodic convolution.
%
%	Y = CONVP(X,H,TS,TY) Returns the periodic convolution of X and H 
%	X, H are vectors or arrays. BOTH MUST BE THE SAME LENGTH
%       TS = sampling interval  [Default: TS = 1].
%	TY = method used and can be 
%	'w'(raparound), 'f'(ft), or 'c'(irculant matrix ) [Default: TY = 'w']
%	If X and H are the same size, Y has the same size as both.
%       If X is a row and H a col, Y is a column vector.
%
%       CONVP (with no input arguments) invokes the following example:
%
%	% Compute the periodic convolution of x[n] = {1 2 3 4} with itself 
%       % and compare the three methods for periodic convolution
%       >>x1 = [1 2 3 4];
%       >>Y1 = convp(x1,x1)	%Default TY = 'w'
%       >>Y2 = convp(x1,x1,'c')
%       >>Y3 = convp(x1,x1,'f')


% ADSP Toolbox: Version 2.0 
% For use with "Analog and Digital Signal Processing", 2nd Ed.
% Published by PWS Publishing Co.
%
% Ashok Ambardar, EE Dept. MTU, Houghton, MI 49931, USA
% http://www.ee.mtu/faculty/akambard.html
% e-mail: akambard@mtu.edu
% Copyright (c) 1998


if nargin==0,help convp,disp('Strike a key to see results of the example')
pause,x1=[1 2 3 4];
Y1=convp(x1,x1),Y2=convp(x1,x1,'c'),Y3=convp(x1,x1,'f'),return,end

if nargin<3,dt=1;ty='w';end
if nargin==3,if isstr(dt),ty=dt;dt=1;else,ty='w';end,end
[mx,nx]=size(x);[my,ny]=size(y);
if mx==1,x=x(:);end,if my==1,y=y(:);end
nx=length(x);ny=length(y);
if nx~=ny,error('vectors must be same length'),end
if ty=='w',Y=[conv(x,y);0];Y=Y(1:nx)+Y(nx+1:2*nx);
elseif ty=='f',Y=ifft(fft(x).*fft(y));
elseif ty=='c',c=convmat(x,nx);Y=c*y;
else
error('unknown convolution method'),return
end
if dt~=1,Y=Y*dt;end,if mx==1 & my==1,Y=Y.';end

⌨️ 快捷键说明

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