[code]if(n <  nmax)speed=new double[n];[/code]
clever! thx! i would have never been able to dream up this code, i learn something new again!

[quote author=Fu-Kwun Hwang link=topic=1487.msg5606#msg5606 date=1269272446]
The histogram find it's number of element from it's own definition.
It was define as speed[nmax] , so the element always use nmax as the number of element for speed.
When you drag slider to change value of n, it does not change the size of the speed array.

So I add [code]if(n <  nmax)speed=new double[n];[/code] at the last line in initlalize page to fix it.

I also un-comment the following at "Brownian" page under "Fixed relations".
//if(!accumulateData) _view.speedHistogram.clear();
The above code will cause error , when there is no data in the histogram (nothing to be clear).

Please check out the attached xml file.


i also added the tip on http://www.um.es/fem/EjsWiki/Main/ElementsHistogram

If the simulation uses [n] array together with a slider for [n], initialize page may need to add code” if(n < nmax)speedarray=new double[n]; “ for histogram to display array correctly as [n]. Check out http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1487.msg5607#msg5607  for in-depth discussion.