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

📄 convmat.m

📁 ADSP TOOLBOX: Version 2.0 and gui m-files
💻 M
字号:
function y =convmat(x,n)
% CONVMAT Circulant matrix for periodic convolution.
%
%	Y = CONVMAT(X,N) returns the NxN circulant matrix for X
%	X = array or vector  
%	N = size of square matrix [Default: N = LENGTH(x)].
%	If length(X) < N, it is zeropadded to length N
%
%	USAGE: If H is a column vector of length(X), the matrix product 
%	Z = CONVMAT(X)*H is the periodic convolution of X and H.
%
%       CONVMAT (with no input arguments) invokes the following example:
%
%	% Let yp = [1;2;3;4] and p = [1;0;3;2]
%	% Find their periodic convolution using wraparound and circulant matrix
%         >>yp = [1;2;3;4];
%         >>yc = convmat(yp),	%Circulant matrix for yp
%         >>p = [1;0;3;2];
%         >>z = yc*p		%periodic conv using circulant matrix
%         >>z1 = convp(yp,p)	%periodic conv using wraparound


% 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 convmat,disp('Strike a key to see results of the example')
pause,yp=[1;2;3;4];yc=convmat(yp),p=[1;0;3;2];z=yc*p,z1=convp(yp,p),return,end

x=x(:).';m=length(x);
if nargin < 2,n=m;end
if n>m,x=[x zeros(1,n-m)];else,n=m;end
y=zeros(n);
for j=1:n-1,y(j,:)=[x(j:-1:1) x(n:-1:j+1)];end
y(n,:)=[y((n-1),n) y((n-1),1:n-1)];

⌨️ 快捷键说明

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