# MATLAB: How to input result looping/iteret (for) to a existing matrix

controlfor loopgainhelpinput matrixinput result for loop to matrixlooplqrMATLABmatrix

how to simple the code below with looping logic(for)? if I have Matrix A(4×4) Bu(4×1)
``R=[510.5];N=[0; 0; 0; 0]; for n = 1:6    x(n)=1650+(1100*(n-1))endfor nn=1:6    X0=x(1,1)    X1=x(1,2)    X2=x(1,3)    X3=x(1,4)    X4=x(1,5)    X5=x(1,6)    %% Matrix Q   Q0=[760 0 0 0; 0 70 0 0; 0 0 X0 0; 0 0 0 0.001];Q1=[760 0 0 0; 0 70 0 0; 0 0 X1 0; 0 0 0 0.001];Q2=[760 0 0 0; 0 70 0 0; 0 0 X2 0; 0 0 0 0.001];Q3=[760 0 0 0; 0 70 0 0; 0 0 X3 0; 0 0 0 0.001];Q4=[760 0 0 0; 0 70 0 0; 0 0 X4 0; 0 0 0 0.001];Q5=[760 0 0 0; 0 70 0 0; 0 0 X5 0; 0 0 0 0.001];%% LQR calculate        [K0,S0,e0] = lqr(A,Bu,Q0,R,N);    [K1,S1,e1] = lqr(A,Bu,Q1,R,N);    [K2,S2,e2] = lqr(A,Bu,Q2,R,N);    [K3,S3,e3] = lqr(A,Bu,Q3,R,N);    [K4,S4,e4] = lqr(A,Bu,Q4,R,N);    [K5,S5,e5] = lqr(A,Bu,Q5,R,N);%% LQR result gainKlqr0=-K0;Klqr1=-K1;Klqr2=-K2;Klqr3=-K3;Klqr4=-K4;Klqr5=-K5;``