Undefined function or method 'filter'
4 views (last 30 days)
Show older comments
hi i am getting an error in this code
% function y = filtdn(x, f, dim, extmod, shift)
% FILTDN Filter and downsample (by 2) along a dimension
%
% y = filtdn(x, f, dim, extmod, shift)
%
% Input:
% x: input signal
% f: 1-D filter
% dim: the processing dimension
% extmod: extension mode (e.g. 'per' or 'sym')
% shift: specifies the window over which filtering occurs
%
% Output:
% y: filtered and dowsampled signal
%
% Note:
% The origin of the filter f is assumed to be floor(size(f)/2) + 1.
% Amount of shift should be no more than floor((size(f)-1)/2).
% Skip singleton dimension
if size(x, dim) == 1
y = x;
return
end
% Cell array of indexes for each dimension
nd = ndims(x);
I = cell(1, nd);
for d = 1:nd
I{d} = 1:size(x,d);
end
% Border extend
n = size(x, dim);
hlf = (length(f) - 1) / 2;
% Amount of extension at two ends
e1 = floor(hlf) + shift;
e2 = ceil(hlf) - shift;
switch extmod
case 'per'
I{dim} = [ly-e1+1:n , 1:n , 1:e2];
case 'sym'
I{dim} = [e1+1:-1:2 , 1:n , n-1:-1:e2];
otherwise
error('Invalid input for EXTMOD')
end
y = x(I{:});
% Filter, downsample, and return only the 'valid' part
y = filter(f, 1, y, [], dim);
I{dim} = (1:2:n) + length(f) - 1;
y = y(I{:});
and the error is ??? Undefined function or method 'filter' for input arguments of type 'uint8'.
Error in ==> filtdn at 54 y = filter(f, 1, y, [], dim);
Filter is an inbuilt function and i have image processing toolbox installed and set in my preferrence ...
can anyone help me with this???
2 Comments
Walter Roberson
on 9 Jan 2017
rani krithiga,
Are you asking about https://www.mathworks.com/matlabcentral/fileexchange/9868-laplacian-pyramid-toolbox/content/lpdemo.m ?? That would not appear to have anything to do with the current Question; please open a new Question about that. Did you look at the comments in the source code for each function?
Accepted Answer
Walter Roberson
on 27 Jun 2012
filter() does not accept arguments of datatype uint8(). You need to filter a single precision or double precision value.
More Answers (2)
Andreas Goser
on 27 Jun 2012
This likely is an overload of multiple FILTER commands. Try
which filter -all
In my installation, it returns:
built-in (C:\Program Files\MATLAB\R2012a\toolbox\matlab\datafun\@single\filter) % single method
built-in (C:\Program Files\MATLAB\R2012a\toolbox\matlab\datafun\@double\filter) % double method
C:\Program Files\MATLAB\R2012a\toolbox\simulink\simulink\@SigLogSelector\filter.m % SigLogSelector method
C:\Program Files\MATLAB\R2012a\toolbox\comm\comm\@gf\filter.m % gf method
C:\Program Files\MATLAB\R2012a\toolbox\comm\comm\@channel\filter.m % channel method
C:\Program Files\MATLAB\R2012a\toolbox\econ\econ\@LagOp\filter.m % LagOp method
C:\Program Files\MATLAB\R2012a\toolbox\dsp\filterdesign\@mfilt\filter.m % mfilt method
C:\Program Files\MATLAB\R2012a\toolbox\dsp\filterdesign\@adaptfilt\filter.m % adaptfilt method
C:\Program Files\MATLAB\R2012a\toolbox\finance\ftseries\@fints\filter.m % fints method
C:\Program Files\MATLAB\R2012a\toolbox\fixedpoint\fixedpointtool\@fxptui\filter.m % fxptui method
C:\Program Files\MATLAB\R2012a\toolbox\mbc\mbctools\@sweepsetfilter\filter.m % sweepsetfilter method
C:\Program Files\MATLAB\R2012a\toolbox\mbc\mbctools\@sweepset\filter.m % sweepset method
C:\Program Files\MATLAB\R2012a\toolbox\signal\signal\@dfilt\filter.m % dfilt method
C:\Program Files\MATLAB\R2012a\toolbox\matlab\timeseries\@timeseries\filter.m % timeseries method
Please see what is at the top for you and consider renaming.
Jan
on 27 Jun 2012
The error message means, that f must not be a uint8 vector. Simply convert it to a double.
See Also
Categories
Find more on Bartlett in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!