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

Why don't you just one one of the many built-in histogram functions?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Histograms에 대해 자세히 알아보기

태그

질문:

2014년 3월 4일

댓글:

2014년 3월 4일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by