Error occurs when creating Pole-Zero Map using pzmap()
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Muhammad Aboawah
am 4 Okt. 2023
Beantwortet: Sam Chak
am 6 Okt. 2023
% Define system parameters
m = 0.5; % kg
l = 1.5; % meters
b = 2; % Nms/rad
g = 9.8; % m/s^2
% Define symbolic variables
syms s tau theta
% Linearized equation of motion
eqn = m * l^2 * s^2 * theta + b * s * theta - m * g * l * theta == tau;
% Solve for transfer function H(s) = Theta(s) / Tau(s)
H = solve(eqn, theta/tau);
% Convert the symbolic transfer function to a function handle
H_function = matlabFunction(H);
% Plot poles of the transfer function
figure;
pzmap(H_function(s, 0), '-'); % '-' for inverted, '+' for upright
title('Pole-Zero Map');
legend('Inverted Configuration', 'Upright Configuration');
0 Kommentare
Akzeptierte Antwort
Sam Chak
am 4 Okt. 2023
The input argument of the pzmap() function from the Control System Toolbox must be specified as a dynamic system model, which is constructed numerically. However, you are working in the symbolic realm, so you must convert the symbolic model to a numerical one.
% Define system parameters
m = 0.5; % kg
l = 1.5; % meters
b = 2; % Nms/rad
g = 9.8; % m/s^2
% Define symbolic variables
syms tau theta(t)
% Linearized equation of motion
eqn = (m*l^2)*diff(theta, 2) + b*diff(theta, 1) - m*g*l*theta == tau
% Reduce ODE to equivalent system of first-order differential equations
[eqs, vars] = reduceDifferentialOrder(eqn, theta(t))
[M, F] = massMatrixForm(eqs, vars);
f = M\F % x' = f(x), where state vector, x = [θ, \dot{θ}]
% Obtain the matrices of the state-space system (in continuous-time)
Ja = jacobian(f, vars); % still in symbolic form
A = double(Ja) % state matrix (convert symbolic Ja to numerical form)
Jb = jacobian(f, tau);
B = double(Jb) % input matrix
C = [1 0]; % output matrix
D = 0; % feedforwand matrix
% Directly convert a state-space into a transfer function
% sys = ss(A, B, C, D)
% Gp = tf(sys)
Gp = tf(ss(A, B, C, D)) % one line only, you don't want to see the state-space
% Plot poles of the transfer function
figure;
pzmap(Gp, 'r'), grid on
3 Kommentare
Sam Chak
am 4 Okt. 2023
You are welcome, @Muhammad Aboawah. If you find the solution helpful, please consider clicking 'Accept' ✔ on the answer to close the issue when the original problem involving pzmap() is resolved.
Additionally, the person who assisted you in writing the code for controller tuning using pidTuner() may be intentionally playing a prank on you.
I suggest that you post a new question, providing the plant transfer function (TF_upright), and specify the practical performance requirements, such as the desired settling time and maximum overshoot, if any. Nobody typically knows the desired poles outright; they often exist in textbooks solely for homework purposes when using the pole placement method.
Weitere Antworten (1)
Sam Chak
am 6 Okt. 2023
I wanted to bring to your attention that, based on the documentation, it appears that the pidTuner() function is unable to accept "desired pole locations" as input and returns "PID gains" as output. In order to achieve the placement of the closed-loop poles at the desired locations, it is necessary to utilize the place() command.
It's worth noting that the place(A, B, p) syntax requires the plant to be defined in state-space representation. Therefore, if one intends to apply the pole placement method to a given plant transfer function, it must first be converted into state-space form. This conversion will allow for the extraction of both the state matrix
and the input matrix
.
To illustrate this process, I have provided an example below that demonstrates how to design a PID controller when the desired pole locations are provided.
% Plant transfer function
Gp = tf(1, [1 3 3 1])
% Define the desired poles for the upright configuration
p = [-2 -3 -4];
% Convert Plant TF to Canonical-Controllable SS
sys = ss(Gp);
sys = compreal(sys, 'c');
A = sys.A'; % state matrix
B = sys.C'; % input matrix
C = sys.B'; % output matrix
% Calculating the optimum gain matrix based on desired poles
K = place(A, B, p);
K = round(K, 4)
% Desired Control System
Csys = ss(A - B*K, -prod(p)*B, C, 0*C*B);
% Control Design using Reverse Engineering
[num1, den1] = tfdata(Csys, 'v');
Gcp = tf(num1(end), [den1(1:3) 0]);
Gc = minreal(Gcp/Gp)
zero(Gc); % 24*(s + 1)*(s + 1)*(s + 1)
pole(Gc); % s*(s^2 + 9*s + 26)
% Filter design
Gf = 24*tf([1 1], [1 9 26]) % 24*(s + 1)/(s^2 + 9*s + 26)
% PID Controller
Gpid = minreal(Gc/Gf, 1e-4) % transfer function form
[num2, den2] = tfdata(Gpid, 'v');
Kp = round(num2(2), 4);
Ki = round(num2(3), 4);
Kd = round(num2(1), 4);
Gpid = pid(Kp, Ki, Kd) % same as (s^2 + 2*s + 1)/s
% Closed-loop transfer function, with Gc = Gpid*Gf
Gcl = minreal(feedback(Gpid*Gf*Gp, 1), 1e-4)
% Check if Gcl poles are placed at desired locations
pole(Gcl)
% Plot the closed-loop step response
step(Gcl, 10), grid on
0 Kommentare
Siehe auch
Kategorien
Mehr zu Stability Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





