Undefined function or method 'unit8'

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 Commenti

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
@Akanchha Tiwari: read the answer below, it explains the bug in your code.

Accedi per commentare.

 Risposta accettata

John D'Errico
John D'Errico il 7 Feb 2015
Modificato: John D'Errico il 27 Apr 2019

3 voti

Perhaps the problem is with your typing or your spelling. ;-)
While unit8 does not exist, uint8 does.
MATLAB can be so picky.

5 Commenti

Thank you!! I've been reading it as UNIT8! It's my first time using Matlab...
The funny thing is I've done exactly the same thing, too frequently. It is a simple typo for me since I do know the spelling, but every once in a while, my (apparently dyslexic) fingers just desperately want to type unit8. Or, since I type without looking at the keyboard, so maybe it is just habit - that when my mind is thinking "uint", the part of my mind that subconsciously controls my fingers to type just sends out the more common word: "unit".
If I had a dollar for every time I've typed "unit8"...
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 il 28 Apr 2019
Modificato: Stephen23 il 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!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su MATLAB in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by