The brownian motion is a function very commonly used in Stochastic Calculus. It is a continous process but not a differentiable function.
The file/function simulate a Brownian Motion Path using the quadratic variation process <W>_t=t
As a word of caution one of the the inputs for the function is t which is not time vector but the upper limit of time till which computation is required ( Eg : t=1sec).
Moreover, to make the function simple and self contained the command "Cumulative-Sum(cumsum)" is not used. This is done to make things clear so that any beginner can also follow the code.
What I do not like:
1) The help is very poor: if I follow it, the function errors when I enter a time vector (e.g., 1:10) and a number of samples (10). Probably t is to be a scalar also, but that is not clear. It has no H1 line, no useful help on its inputs or outputs, no example.
2) It has no error checks on its inputs, checking for common mistakes (like no scalar inputs).
3) It is poorly programmed, calculating unused variables, etc, setting the rand state without warning, no internal comments
4) it is very trivial, and can be coded in one line: "w = [0 ; cumsum(sqrt(t/n).*rand(n-1,2))]; "
Finaly, try to make clear why anybody wishes to use of this function.
I think this submission is to be rated 1.5 stars ...