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 because
of some mismatch assignments. I think I am making some mistakes in the array assignments. I'd appreciate any hints or comments. Thanks
Asked
Active
Viewed 308 times
1
Mary
- 65
-
For one thing, you haven't defined Rn and m. Also you might use A(1,:,:) rather than A(1) etc, or use A{1} for a cell array. – Robert Israel Oct 26 '16 at 15:20
-
@RobertIsrael, Here I call the function Rn(m,n) which is defined and saved. The error is not related to Rn though. I got a mismatch dimension error in the assignment of A(1). I tried {} before and I got the same error. – Mary Oct 26 '16 at 15:25
-
Another problem is that Rn is called with two arguments in line 10 and only one in line 11. – Robert Israel Oct 26 '16 at 19:16
-
@RobertIsrael, right, thank you. However, the debuger stops at the very first line where A(1) or A{1} is eye(2), it does not go any further. – Mary Oct 27 '16 at 01:16
