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!