Reputation: 3959
I have a vector that used to be a matrix, I changed it into a vector using x = y(:), then I created my vector, now I want to create a histogram i keep getting following errors:
Error using .*
Integers can only be combined with integers of the same class, or scalar doubles.
Error in hist (line 78)
xx = miny + binwidth*(0:x);
this is my code:
>> y = part(:);
>> hist(part(:))
can someone help me as I am new to matlab, what am I doing wrong here?
NEW EDIT: here is my complete code: where I try to change an image to completely red and then take some part of the image, finally making it into a histogram:
>> rgb = uint8( imread('hand.tif') );
>> imagesc(rgb);
>> red = rgb( :,:,1);
>> green = rgb( :,:,2);
>> blue = rgb( :,:,3);
>> pure_red = red ./ (red+blue+green);
>> imagesc(pure_red);
>> part = pure_red(1:10,1:10);
>> y = part(:);
Upvotes: 0
Views: 476
Reputation: 5126
You can try to convert the data to double:
y = double(part(:));
figure;
hist(y);
Upvotes: 1