downsample fuction error, I want to know how to design the downsampling filter
Show older comments
x = [1 2 3 4 5 6 7 8 9 10];
y = downsample(x,3)
y =
9 27 45 63 81
I want to know how to design the downsampling filter. I run the code on matlab2015b and the answer is wrong. so I consult the downsampling function. but I don't know how to design the filter. the following is the code of the downsample function provided by matlab:
% Downsampling procedure.
%
% Arguments:
% grayscale I image
% downsampling filter 'filter', should be a 1D separable filter.
% 'border_mode' should be 'circular', 'symmetric', or 'replicate'. See 'imfilter'.
%
% If image width W is odd, then the resulting image will have width (W-1)/2+1,
% Same for height.
%
% tom.mertens@gmail.com, August 2007
%
function R = downsample(I, filter)
border_mode = 'symmetric';
% low pass, convolve with separable filter
R = imfilter(I,filter,border_mode); %horizontal
R = imfilter(R,filter',border_mode); %vertical
% decimate
r = size(I,1);
c = size(I,2);
R = R(1:2:r, 1:2:c, :);
Answers (1)
Honglei Chen
on 23 Nov 2015
0 votes
This is a third party program and is not provided by MathWorks. I don't know what your goal is but the function is doing what exactly it's asked to do. From the comment, the function is meant to be used with an image, not a 1D signal. HTH
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!