Hi, I am facing some problem in iterating my equations. Basically, here how it should work.
A(i)= x1*B(i) + x2*B(i-1)
B(i)= x3*A(i) + x4*A(i-2)
A(i)= x5*B(i-1) + x6*A(i-2)
B(i)= x7*B(i-1) + x8*A(i-2)
where x1,x2,x3,x4,x5,x6,x7,and x8 are all known constansts. Assume i is 7 and A(7),A(0),B(7),B(0) are known, and A(3) and B(3) need to be determined.
Starting from
A(7) = B(6) + A(5)
=B(5)+A(4) + B(4)+A(3) (using equation 3 and 4) =B(4)+A(3) + B(3)+A(2) + B(3)+A(2) + B(2)+A(1) (using equation 3 and 4) =B(3)+A(2) + B(2)+A(1) + B(2)+A(1) + B(1)+A(0) + B(2)+A(1) + B(1)+A(0) + B(1)+A(0) + B(1)+B(0) (using equation 1,3,4. When it comes to A(1), we have to switch to equation 1 to prevent A(-1)) =B(2)+A(1) + B(1)+A(0) + B(1)+A(0) + B(1)+B(0) + B(1)+A(0) + B(1)+B(0) + B(1) + A(0) + B(1)+A(0) + B(1)+B(0) + B(1) + A(0) + B(1) + A(0) +B(1) + B(0) = 12B(1)+7A(0)+5B(0)Using the same way,
A(6)=8B(1)+4A(0)+3B(0)
A(5)=3B(1)+3A(0)+2B(0)
A(4)=3B(1)+2A(0)+B(0)
A(3)=2B(1)+A(0)+B(0)
A(2)=B(1)+A(0)
(The known constants coefficients are ignored at here for simplicity but it does exist.)
Originally my idea was trying to iterate in the way that when i of A(i) or B(i) is bigger than 1, then it will substitute in equation 3 and 4. While i is equal to 1, then it will substitute in equation 1 and 2. This process will keep iterating until the equation is left with one unknown. But I could not implement this in Matlab as I have no idea how to use loop for the substitution n this case.
Best Answer