How to define this recursive formula in MatLAB

309 Views Asked by At

I have a matrix-valued function defined as R which depends on n and I want to define the following algorithm in MatLAB: $A_{0}=I$ , $B_{0}=0$ , $A_{1}=I$ ,$B_{1}=I$ for $j=1:2m$
$A_{j}= R_{j}A_{j-1}+A_{j-2}$;$B_{j}= R_{j}B_{j-1}+B_{j-2};$ end $K_{m}=A_{2m}B_{2m}$, I have the following code in MatLAB, it does not work becauseenter image description here of some mismatch assignments. I think I am making some mistakes in the array assignments. I'd appreciate any hints or comments. Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

Here is an example with cell arrays.

enter image description here