Undefined function or variable 'ordf'.

4 Ansichten (letzte 30 Tage)
Yan Gong
Yan Gong am 22 Okt. 2016
Bearbeitet: per isakson am 11 Jan. 2017
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 Kommentare
Geoff Hayes
Geoff Hayes am 22 Okt. 2016
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 am 23 Okt. 2016
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Yan Gong
Yan Gong am 11 Jan. 2017
Bearbeitet: per isakson am 11 Jan. 2017
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 Kommentar
per isakson
per isakson am 11 Jan. 2017
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

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by