Undefined function or method 'unit8'

12 Ansichten (letzte 30 Tage)
Dee T
Dee T am 7 Feb. 2015
Bearbeitet: Stephen23 am 28 Apr. 2019
I am getting this error when using unit8:
??? Undefined function or method 'unit8' for input arguments of type 'double'.
I have MATLAB Version 7.12.0.635 (R2011a) and unit8.m does not exist in MATLAB folder. Please help
Code mask=unit8(mask); eye_image=gray_image .* mask; figure, imshow(eye_image), hold on; title('Eye Image');
  2 Kommentare
Akanchha  Tiwari
Akanchha Tiwari am 27 Apr. 2019
i got error in my code this
Undefined function or variable 'unit8'.
Error in baseme (line 34)
ima= unit8(img1); % read image
how to over come it
Stephen23
Stephen23 am 27 Apr. 2019
@Akanchha Tiwari: read the answer below, it explains the bug in your code.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

John D'Errico
John D'Errico am 7 Feb. 2015
Bearbeitet: John D'Errico am 27 Apr. 2019
Perhaps the problem is with your typing or your spelling. ;-)
While unit8 does not exist, uint8 does.
MATLAB can be so picky.
  5 Kommentare
John D'Errico
John D'Errico am 27 Apr. 2019
I suppose, if this was too often a problem, one could define a pass-through function called unit8, that just calls uint8.
function X = unit8(varargin)
% synonym for uint8 for those who never get the spelling right
X = uint8(varargin{:});
Stephen23
Stephen23 am 28 Apr. 2019
Bearbeitet: Stephen23 am 28 Apr. 2019
"...one could define a pass-through function called unit8..."
Not convinced. That would just hide the problem even deeper, and totally flumox the user when unit8 is eventually not accessible (which it inevitably will be, e.g. when the path is changed, scope changes due to moving files around, confusion during debugging, etc). Combined with beginners' enthusiasm for (slow and anti-pattern) cd this is just asking for trouble!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by