Histogram: What is wrong with this code?

136 Views Asked by At

I've got some issues while trying to plot an histogram using Octave, in order to compare it with a p.d.f. given.

1) First of all, I can't find the best way to make an histogram with the frequencies of appearance of each value. I've used the commands below(It is a fragment of the actual code).

2) Also, although at first the histogram was being shown correctly, now it doesn't show up. When I run the code, the plot appears,but it has only the p.d.f. in it.

    g=[]; 
    for i=1:ensayos 
            g=[g,TiempoMuerte_Cte(N,c)]; 
    endfor 
    h = hist(g,ensayos,1) 
    hold on 
    x = 0:0.1:30; 
    x_2=exp(-x) - x/(N)- 1; 
    f = N*exp(N*(x_2)); 
    plot(x,f) 

Am I missing some piece of code?

Thank you very much