"feedback" function example in Matlab documentation doesn't seem to work?

3 visualizzazioni (ultimi 30 giorni)
I am trying to reproduce Example 2 in the documentation for the function "feedback" in Matlab2014a.
The example :
Consider a state-space plant P with five inputs and four outputs and a state-space feedback controller K with three inputs and two outputs. To connect outputs 1, 3, and 4 of the plant to the controller inputs, and the controller outputs to inputs 4 and 2 of the plant, use
feedin = [4 2];
feedout = [1 3 4];
Cloop = feedback(P,K,feedin,feedout)
My code :
P = rss(4,4,5);
K = rss(2,2,3);
feedin = [4 2];
feedout = [1 3 4];
Cloop = feedback(P,K,feedin,feedout);
size(Cloop)
Result:
Instead of returning a 3 input, 1 output closed-loop system, Matlab gives a system of the same size as P:
State-space model with 4 outputs, 5 inputs, and 6 states.
Why isn't this working properly?
  1 Commento
Yenni
Yenni il 8 Mag 2024
Spostato: Sam Chak il 8 Mag 2024
clc
clear all
close all
close all hidden
%
% Fungsi Alih Lingkar Tertutup
disp('Fungsi Alih Lingkar Tertutup Tanpa Pengendali Proporsional (P)')
Fungsi Alih Lingkar Tertutup Tanpa Pengendali Proporsional (P)
[num_op,den_op] = cloop(num_ol,den_ol,-1);
Unrecognized function or variable 'num_ol'.
sys_cl = tf(num_op,den_op)
%

Accedi per commentare.

Risposte (1)

Sam Chak
Sam Chak il 8 Mag 2024
Using the 'feedback()' command to compute the closed-loop model with the specified input and output connections doesn't affect the number of inputs and outputs. However, if there are any cancellable poles and zeros, some states will be eliminated. The number of outputs and inputs is reflected in the tiled chart layout, which has the number of rows (outputs) by columns (inputs) of tiles in the response plot.
%% State-space Proces
Ap = [0, 1; -1, -2];
Bp = [0; 1];
Cp = eye(size(Ap));
Dp = 0*Cp*Bp;
P = ss(Ap, Bp, Cp, Dp);
size(P)
State-space model with 2 outputs, 1 inputs, and 2 states.
%% State-space Kontroler
Ak = [0, 1; 0, -2];
Bk = [0; 1];
Ck = [1, 0];
Dk = 1;
K = ss(Ak, Bk, Ck, Dk);
size(K)
State-space model with 1 outputs, 1 inputs, and 2 states.
%% Closed-loop system (before pole-zero cancellation)
feedin = [1]; % feed [Pin(1)] from [Kout(1)]
feedout = [1]; % feed [Pout(1)] to [Kin(1)]
Cloop = feedback(K*P, 1, feedin, feedout, -1);
size(Cloop)
State-space model with 2 outputs, 1 inputs, and 4 states.
%% Closed-loop system (after pole-zero cancellation)
Cloop = minreal(Cloop)
2 states removed. Cloop = A = x1 x2 x1 -1.565 -0.1752 x2 1.825 -0.4346 B = u1 x1 -1.251 x2 0.6592 C = x1 x2 y1 -0.3296 -0.6256 y2 -0.6256 0.3296 D = u1 y1 0 y2 0 Continuous-time state-space model.
size(Cloop)
State-space model with 2 outputs, 1 inputs, and 2 states.
%% Step response
step(Cloop), grid on

Categorie

Scopri di più su Dynamic System Models in Help Center e File Exchange

Prodotti


Release

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by