Undefined function or variable 'ordf'.

조회 수: 4 (최근 30일)
Yan Gong
Yan Gong 2016년 10월 22일
편집: per isakson 2017년 1월 11일
I want to use medfilt2 inside a function, but when I run the code it always gives me that error message saying it is undefined. Could someone give suggestions on how to solve it? Thanks!
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2016년 10월 22일
Yan - how does calling the medfilt2 generate the error concerning ordf? Please show some of the code that generates this error and copy and paste the full error message to your question.
Walter Roberson
Walter Roberson 2016년 10월 23일
I searched through all of the Mathworks-supplied .m files I have installed in my R2016b installation, and do not find any occurrences of a variable named ordf, so it sounds like the difficulty is in code you (or a third-party toolbox) have supplied.

댓글을 달려면 로그인하십시오.

답변 (1개)

Yan Gong
Yan Gong 2017년 1월 11일
편집: per isakson 2017년 1월 11일
So here is a simple case of me calling the function medfilt2. I just randomly created a matrix and applied the filter to it:
>> A=[1 3 3 5 1;0.5 3 0 9 2;1 1 1 1 1;0.4 1.9 24 3.2 5;0 -1 2.7 30 5]
A =
1.0000 3.0000 3.0000 5.0000 1.0000
0.5000 3.0000 0 9.0000 2.0000
1.0000 1.0000 1.0000 1.0000 1.0000
0.4000 1.9000 24.0000 3.2000 5.0000
0 -1.0000 2.7000 30.0000 5.0000
>> B=medfilt2(A,[3 3],'symmetric');
Undefined function or variable 'ordf'.
Error in ordfilt2 (line 83)
B = ordf(A, order, offsets, [padSize padSize] + 1, ...
Error in medfilt2 (line 53)
b = ordfilt2(a, order, domain, padopt);
And this error message popped out all the time. I have the image processing toolbox installed in my R2016b, so I'm sure that medfilt2 can be found.
So what would cause such problem? Thanks!!
  댓글 수: 1
per isakson
per isakson 2017년 1월 11일
Run
dbstop if error
B=medfilt2(A,[3 3],'symmetric');
and try to understand what's going on.
On my R2016a it seems to work fine
>> dbstop if error
A=[1 3 3 5 1;0.5 3 0 9 2;1 1 1 1 1;0.4 1.9 24 3.2 5;0 -1 2.7 30 5];
B=medfilt2(A,[3 3],'symmetric');
B
B =
1.0000 3.0000 3.0000 3.0000 2.0000
1.0000 1.0000 3.0000 1.0000 1.0000
1.0000 1.0000 1.9000 2.0000 2.0000
0.4000 1.0000 1.9000 3.2000 5.0000
0 0.4000 2.7000 5.0000 5.0000
>> version
ans =
9.0.0.341360 (R2016a)
In R2016a the code is different; line 82-90 of c:\Program Files\MATLAB\R2016a\toolbox\images\images\ordfilt2.m reads
if isempty(s)
%ORDFILT2(A,ORDER,DOMAIN)
B = ordfilt2mex(A, order, offsets, [padSize padSize] + 1, ...
originalSize, domainSize);
else
%ORDFILT2(A,ORDER,DOMAIN,S,PADOPT)
B = ordfilt2mex(A, order, offsets, [padSize padSize] + 1, ...
originalSize, domainSize, s);
end

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Digital Filtering에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by