Matlab直方图误差

Matlab直方图误差,matlab,histogram,Matlab,Histogram,我有一个曾经是矩阵的向量,我用x=y(:)把它变成了向量, 然后我创建了我的向量,现在我想创建一个直方图,我不断得到以下错误: 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); 这是我的代码: >> y = part

我有一个曾经是矩阵的向量,我用x=y(:)把它变成了向量, 然后我创建了我的向量,现在我想创建一个直方图,我不断得到以下错误:

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);
这是我的代码:

>> y = part(:);
>> hist(part(:))
有人能帮我吗,因为我是matlab新手,我在这里做错了什么

新编辑: 以下是我的完整代码:我尝试将图像更改为完全红色,然后提取图像的一部分,最后将其制成直方图:

>> 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(:);

您可以尝试将数据转换为双精度:

y = double(part(:));

figure;
hist(y);

问题出在可变部分,所以我们需要看看是什么部分,或者是如何创建的,以便提供帮助。