Undefined function or method 'filter'
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
Walter Roberson
2017-1-9
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?
采纳的回答
Walter Roberson
2012-6-27
filter() does not accept arguments of datatype uint8(). You need to filter a single precision or double precision value.
更多回答(2 个)
Andreas Goser
2012-6-27
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
2012-6-27
The error message means, that f must not be a uint8 vector. Simply convert it to a double.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Bartlett 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!