histogram function, matlab doesnt like my dx
古いコメントを表示
Hey, I am trying to create a function for histogram that takes i the vector v, with n bins and in the interval [a,b]. I created the function but matlab tells me that I using arguments of type 'double'. I think it is because it doesn't like dx not being an integer but I have no idea what to do. Can you please help?
this is my code:
if true
function histarray=myhist(v,a,b,n)
histarray=zeros(1,n);
dx=(b-a)./n;
x=a:dx:b;
for i=1:length(x)
for k=1:length(v)
if (x(i)<=v(k)) && (v(k)<=(x(i)+dx))
histarray(i)=histarray(i)+1;
end
end
end
bar(x,histarray)
end
end
I will really appreciate any help. Kasia
1 件のコメント
Image Analyst
2014 年 3 月 4 日
Why don't you just one one of the many built-in histogram functions?
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Histograms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!