diff options
author | shamikam | 2017-11-07 15:59:48 +0530 |
---|---|---|
committer | shamikam | 2017-11-07 15:59:48 +0530 |
commit | c0c0582462720ed597b00e116506570577614e89 (patch) | |
tree | 31dedd23698e5357b19c810b7d7a8464100ef44a /macros/convmtx.sci | |
download | FOSSEE-Signal-Processing-Toolbox-c0c0582462720ed597b00e116506570577614e89.tar.gz FOSSEE-Signal-Processing-Toolbox-c0c0582462720ed597b00e116506570577614e89.tar.bz2 FOSSEE-Signal-Processing-Toolbox-c0c0582462720ed597b00e116506570577614e89.zip |
initial commit
Diffstat (limited to 'macros/convmtx.sci')
-rw-r--r-- | macros/convmtx.sci | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/macros/convmtx.sci b/macros/convmtx.sci new file mode 100644 index 0000000..c0aa891 --- /dev/null +++ b/macros/convmtx.sci @@ -0,0 +1,36 @@ +//Convolution Matrix +//convmtx(h,n) returns the convolution matrix for vector h. If h is a +//column vector and X is a column vector of length n, then convmtx(h,n)*X +//gives the result of the convolution oof h and X.If R is a row vector and X//is a row vector of length N, then X*convmtx(R,N) gives the convolution of R and X. +//Example: +//Generate a simple convolution matrix. +// +// h = [%i 1 2 3]; +// convmtx(h,7) //Convolution matrix +// +//Author +//Debdeep Dey +function t=convmtx(v,n); + n=double(n); + [mv,nv]=size(v); + v=v(:); + + //put Toeplitz code inline + c = [v; zeros(n-1,1)]; + r = zeros(n,1); + m = length(c); + x = [r(n:-1:2) ; c(:)]; + + cidx = (0:m-1)'; + ridx = n:-1:1; + t = cidx(:,ones(n,1)) + ridx(ones(m,1),:); //Toeplitz subscripts + t(:) = x(t); //actual data + + //t = single(t); + // end of toeplitz code + +if mv < nv then + t = t.'; + end + +endfunction |