Block matrix indexing
Hello this might be a stupid question but i need some help indexing a Matlab matrix consisting of several sub-matrices.
for k = 1:tf-1
r(k) = rand(1)/4;
u(k+1) = 0.5;
x1(k+1) = A(1,1)*x1(k) + A(1,2)*x2(k) + B(1,1)*u(k);
x2(k+1) = A(2,1)*x1(k) + A(2,2)*x2(k) + B(2,1)*u(k);
x = [x1(k) x2(k)]';
y(k) = C*x + r(k);
P_prior(k+1) = A*P(k)*A.' + Q;
K(k+1) = P_prior(k+1)*C.'/(C*P_prior(k+1)*C.' + R);
xhat(k+1) = x(k+1) + K(k+1)*(y(k) - C*x(k+1));
P(k+1) = (eye(size(1,1)) - K(k+1)*C)*P_prior(k+1);
end
For example i want to populate P_prior with several 2x2 matrices and the k index to stand for 1st block matrix, second, etc. Is there even a way to do this with Matlab or do i have to come around another way?
Thank you in advance.
Category Data Science