MATLAB: The own imhist function error

functions imhistImage Processing Toolboximhistvalue imhist

Hello, iam new in matlab, and i have some questions about this function i made. my teacher wants us to do our own imhist, and i did this. my question is, iam using a double image and it gives an error, what i should change in this function to works fine with double image.
( Attempted to access vetor(1.01519); index must be a positive integer or logical.)
function img2 = HistOnMyOwn(image)
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
img2=image;
im2double(img2);
vetor=zeros(256,1);
for i=1:size(img2,1)
for j =1:size(img2,2)
vetor(img2(i,j)+1) = vetor(img2(i,j)+1)+1;
end
end
plot(vetor);
end

Best Answer

This oughtta make it pretty clear:
im2double(uint8(1:10:255))