Error using InputOutpu​tModel/fee​dback (line 137) The first and second arguments of the "feedback" command must have compatible I/O sizes.

조회 수: 15 (최근 30일)
clear
format compact
M1 = 10; M2 = 1; K = 1000;
% 制御対象 the system without control
A = [0 0 1 0
0 0 0 1
-K/(M1) K/(M1) 0 0
K/(M2) -K/(M2) 0 0];
B=[0
0
1/(M1)
0];
C=[1 0 0 0
0 1 0 0];
sys_ex=ss(A, B, C, 0);
sys_ex.OutputName={'x1','x2'};
% 安定性のチェック check stability
eig(A)
% 可制御性のチェック check controllability
n=size(A,1)
Vc=ctrb(sys_ex)
if(rank(Vc)==n)
disp(' The system is ontrollable')
else
disp(' The system is uncontrollable')
end
% 所望の極の設定 Desired poles
%lambda = [-5, -4]
lambda = [-3-3j, -3+3j, -2-2j, -2+2j]
% 極配置によるゲイン行列を求める pole placement
F = - place(A, B, lambda) % note: switch negative feedback to positive feedback
% 状態フィードバック state feedbak
sys_ex_fdbk = feedback(sys_ex, F, +1);
% ステップ応答 step response
figure(20), clf
step(sys_ex,3);
hold on
step(sys_ex_fdbk,3);
hold off
legend('without control', 'with control')
grid on
  댓글 수: 3
LONG NGUYEN THANH
LONG NGUYEN THANH 2023년 5월 20일
This is my code
clear
format compact
M1 = 10; M2 = 1; K = 1000;
% 制御対象 the system without control
A = [0 0 1 0
0 0 0 1
-K/(M1) K/(M1) 0 0
K/(M2) -K/(M2) 0 0];
B=[0
0
1/(M1)
0];
C=[1 0 0 0
0 1 0 0];
sys_ex=ss(A, B, C, 0);
sys_ex.OutputName={'x1','x2'};
% 安定性のチェック check stability
eig(A)
% 可制御性のチェック check controllability
n=size(A,1)
Vc=ctrb(sys_ex)
if(rank(Vc)==n)
disp(' The system is ontrollable')
else
disp(' The system is uncontrollable')
end
% 所望の極の設定 Desired poles
%lambda = [-5, -4]
lambda = [-3-3j, -3+3j, -2-2j, -2+2j]
% 極配置によるゲイン行列を求める pole placement
F = - place(A, B, lambda) % note: switch negative feedback to positive feedback
% 状態フィードバック state feedbak
sys_ex_fdbk = feedback(sys_ex, F, +1);
% ステップ応答 step response
figure(20), clf
step(sys_ex,3);
hold on
step(sys_ex_fdbk,3);
hold off
legend('without control', 'with control')
grid on

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

답변 (1개)

Atsushi Ueno
Atsushi Ueno 2023년 5월 20일
편집: Atsushi Ueno 2023년 5월 20일
> please tell me what's wrong in my code
You have to specify one more dynamic system model "sys2" at feedback function.
  • The feedback part "sys2" does not have to be a state-space model
  • The example below specify a state-space model with all zeros, so it affects nothing as feed back loop.
M1=10; M2=1; K=1000;
A = [0 0 1 0; 0 0 0 1; -K/(M1) K/(M1) 0 0; K/(M2) -K/(M2) 0 0];
B = [0; 0; 1/(M1); 0];
C = [1 0 0 0; 0 1 0 0];
sys_ex = ss(A, B, C, 0); % main transfer function
size(sys_ex);
State-space model with 2 outputs, 1 inputs, and 4 states.
sys_fdbk = ss(zeros(4),zeros(4,2),zeros(1,4),zeros(1,2)); % feedback transfer function
size(sys_fdbk);
State-space model with 1 outputs, 2 inputs, and 4 states.
sys_ex_fdbk = feedback(sys_ex,sys_fdbk,1);
  댓글 수: 2
Atsushi Ueno
Atsushi Ueno 2023년 5월 21일
The problem is feedback function connects sys1's output and sys2's input.
But the feedback gain K's input is not "output y" but "state x".
Atsushi Ueno
Atsushi Ueno 2023년 5월 21일
Also, the output from pole function is not dynamic system model but factor. So, you should use ss function again to make whole dynamic system model with feedback again.
M1=10; M2=1; K=1000;
A = [0 0 1 0; 0 0 0 1; -K/(M1) K/(M1) 0 0; K/(M2) -K/(M2) 0 0];
B = [0; 0; 1/(M1); 0];
C = [1 0 0 0; 0 1 0 0];
sys_ex = ss(A, B, C, 0); % main transfer function
lambda = [-3-3j, -3+3j, -2-2j, -2+2j];
F = - place(A, B, lambda); % note: switch negative feedback to positive feedback
sys_ex_fdbk = ss(A+B*F,B,C,0); %feedback(sys_ex, F, +1); % transfer function with the feedback
Pcl = pole(sys_ex_fdbk)
Pcl =
-2.0000 + 2.0000i -2.0000 - 2.0000i -3.0000 + 3.0000i -3.0000 - 3.0000i

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

카테고리

Help CenterFile Exchange에서 古典制御設計에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!