필터 지우기
필터 지우기

Subscripted assignment dimension mismatch.

조회 수: 2 (최근 30일)
rupal
rupal 2022년 5월 26일
댓글: rupal 2022년 5월 27일
When I changed the value of C from [0 1] to eye(2) I am getting the following error:
Subscripted assignment dimension mismatch.
Error in set_quasi (line 46)
Phi( (i-1)*nu+1:i*nu, (i-1)*nx+1:i*nx) = Ctid
Please help me to resolve this.
I have attached my code also.
clc
clear
% define model parametres
Kp=3.3; Ao1=0.1781; Ao2=0.1781; At1=15.5179;At2=15.5179; g=981;Le1=15; Le2=15;
Ac=[(-Ao1*sqrt(g/(2*Le1))/At1) 0;(Ao1*sqrt(g/(2*Le2))/At2) (-Ao2*sqrt(g/(2*Le2))/At2)];
Bc=[Kp/At1;0];
Cc=[0 1];
%discrete time model
dt=0.01; %sampling time
sys=ss(Ac,Bc,Cc,0);
ds=c2d(sys,dt);
Ad=ds.a; Bd=ds.b; Cd= ds.c;
N = 9;
u_max = 18;
u_min = 2;
Atid=[Ad zeros(2,1);eye(1) zeros(1,2)];
Btid=[Bd;zeros(1)];
Ctid=[Cd zeros(1)];
% Number of states and control signals
nx = size(Atid,2);
nu = size(Btid,2);
% LQR values
Q_mat =[Ctid'*Ctid];
S = eye(nu);
R = 0.00001;
[~,P,~] = dlqr(Atid,Btid,Q_mat,R);
%% Reference Parameters
% Initilize matrices
% xf = zeros(1:nx)';
xf = [15 15 0]';
% Initilize QP matrices
Psi = zeros(nx*N, nx);
Omega = zeros(nx*N, nu*N);
Phi = zeros(nu*N, nx*N);
H11 = zeros(nu*N,nu*N);
H22 = zeros(nx*N,nx*N);
H33 = zeros(nu*N,nu*N);
H44 = [zeros(nx,nx*(N-1)) eye(nx)];
% Construct QP matrices
for i = 1:N
Psi( (i-1)*nx+1:i*nx, :) = Atid^i;
Phi( (i-1)*nu+1:i*nu, (i-1)*nx+1:i*nx) = Ctid
H11( (i-1)*nu+1:i*nu, (i-1)*nu+1:i*nu) = R;
if i<N
H22( (i-1)*nx+1:i*nx, (i-1)*nx+1:i*nx ) = Q_mat;
H33( (i-1)*nu+1:i*nu, (i-1)*nu+1:i*nu ) = S;
else
H22( (i-1)*nx+1:i*nx, (i-1)*nx+1:i*nx ) = P;
end
for j=1:i
Omega( (i-1)*nx+1:i*nx, (j-1)*nu+1:j*nu ) =[Atid^(i-j)*Btid] ;
end
end
  댓글 수: 4
Torsten
Torsten 2022년 5월 26일
rupal
rupal 2022년 5월 27일
Thanks for the help .I resolved the issue.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

제품


릴리스

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by