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

13 ビュー (過去 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 Center および File Exchange古典制御設計 についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!