-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_root_locus.m
More file actions
27 lines (24 loc) · 840 Bytes
/
plot_root_locus.m
File metadata and controls
27 lines (24 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function plot_root_locus(poles, zeros)
% plot_root_locus - Plots the root locus of a system defined by pole-zero map
%
% Syntax:
% plot_root_locus(poles, zeros)
%
% Inputs:
% poles - Vector of complex pole locations (e.g., [-2 -3 + 4i -3 - 4i])
% zeros - Vector of complex zero locations (e.g., [-1 + 2i -1 - 2i])
%
% Example:
% plot_root_locus([-2 -3+4i -3-4i], [-1+2i -1-2i])
% Create transfer function numerator and denominator from zeros and poles
s = tf('s');
num = poly(zeros); % Coefficients of numerator polynomial
den = poly(poles); % Coefficients of denominator polynomial
% Construct open-loop transfer function with symbolic gain K
G = tf(num, den);
% Plot root locus
figure;
rlocus(G);
title('Root Locus Plot');
grid on;
end