From: Harrison Jostrom on 8 May 2010 18:56 Hi, Trying to execute the following function in matlab but have had limited success. n=2^ndx; x(1) = 0; x(n+1) = randn(1,1)*2^(ndx*H); s(1) = sqrt(1 - 2^(2*H - 2)); for i = 1:n s(i+1) = 2^(-H)*s(i); end for i = 1:ndx for j = 0:2^(i-1)-1 k = 2^(ndx+1-i); Q = randn(1,1)*2^(H*ndx)*s(i+1); x((k*j + k*(j+1) + 1)/2) = (x(k*j+1) + x(k*(j+1)+1))/2 + Q; end end The resulting error message says that the subcript indices must real positive integers or logicals. I'm not too well versed with matlab, so any assistance will likely be of great help to me
From: dpb on 8 May 2010 20:20 Harrison Jostrom wrote: .... > for i = 1:ndx > for j = 0:2^(i-1)-1 .... What's j for i=1??? --
From: Walter Roberson on 8 May 2010 21:38 Harrison Jostrom wrote: > k = 2^(ndx+1-i); So k would be even > x((k*j + k*(j+1) + 1)/2) = (x(k*j+1) + x(k*(j+1)+1))/2 + Q; Since k is even, k*j and k*(j+1) are both even, so adding 1 to their sum will be odd. Dividing an odd number by 2 will give a fractional result of 1/2, and a number with a fractional in it is not an integer.
|
Pages: 1 Prev: no true date iteration in matlab Next: Passing parameters in function handles for ode45 |