I've tried to find the answer to this simple for loop question but I can't find any tutorials on it. I'm trying to calculate a specific entry of a column vector but the error "Error in MuPAD command: DOUBLE cannot convert the input expression into a double array" keeps showing up. I'm pretty sure that both entries in the for loop should come up as scalar functions of u1,...,u20 but I must be doing something wrong. My script reads as follows:
U = sym('u', [21 1]);
P(1,1) = 1;
Q(1,1) = 0;
for k = 1:20
P(k+1,1) = 1/20*(-.3*P(k,1) +.65*Q(k,1)+U(k,1))+P(k,1);
Q(k+1,1) = 1/20*(-.65*Q(k,1) + .3*P(k,1)-U(k,1))+Q(k,1);
end
P(21,1)
Q(21, 1)
Any help would be greatly appreciated.