When I run below code, I get error: Index exceeds the number of array elements (5).
Can someone please help me understand why I'm getting this error? As for loop is processed 5 times (in below example), shouldnt I get matrix size of 1×5 of 'n' values? like n= [1 0 1 2 3]?
Thank you
>> r=exprnd(1/8, 1,5); >> at=cumsum(r); >> st=exprnd(1/8, 1, 5); >> n = 0; >> ord=2:1:6; >> n=0;>> for x=1:5; %x defines # of sims
if at(ord-1) + cumsum(st(ord-1)) ==at(ord)n=nelseif at(ord-1) + cumsum(st(ord-1)) < at(ord)n=n-1else n=n+1plot(n)endend
Best Answer