histogram function, matlab doesnt like my dx
Mostrar comentarios más antiguos
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 comentario
Image Analyst
el 4 de Mzo. de 2014
Why don't you just one one of the many built-in histogram functions?
Respuestas (0)
Categorías
Más información sobre Histograms en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!