0% found this document useful (0 votes)
136 views5 pages

Root Locus Matlab Code

A control systems (MC450) assignment solution on root locus

Uploaded by

Chris Mwape Jr.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
136 views5 pages

Root Locus Matlab Code

A control systems (MC450) assignment solution on root locus

Uploaded by

Chris Mwape Jr.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
le % Clear connand window. clear % Clear all variables from the workspace. % Plant rung = [8.513 % Numerator of G(s) for the plant. deng = [12 20 10]; % Denominator of G(s) for the plant. isp("PLANT TRANSFER FUNCTION" ) G = t#(nurg, deng) % Create and display the transfer function G(s). POLE ZERO PLOT Figure; pznap(6) % ROORLOCUS Figures % Open a new Figure window. rlocus(6) % Plot the root locus of the open-loop transfer function G(s) ‘title('ROOTLUCUS FOR THE UNCOMPENSATED SYSTEM" ) % PD Controller une = (1 1]3 % Numerator of the PD controller transfer function. dene = [1]; % Denoninator of the PD controller transfer function. disp("PD TRANSFER FUNCTION" ) Gc = tf(nume, denc) % Create the transfer function for the PD controller. T= 64 Gc; % Combine the plant with the PD controller. Figures % Open a new Figure window. locus (TT % Plot the root locus of the combined system axis((-3.33, 1, -1, 1]) % Set axis Limits for the root locus plot. ‘title('ROOTLUCUS FOR THE PO COMPENSATED SYSTEM" ) % PL Controller hun = [2 @.9]5 % Numerator of the PL controller transfer function. dent = (1 @]; % Denoninator of the PI controller transfer function. isp("PL TRANSFER FUNCTION" ) si = tf(numt, dent) % Create the transfer function for the PI controller. Gisp("COMPESATED TRANSFER FUNCTION’ ) Tr = 11 * Gi % Combine the systen with both PD and PI controllers. Figures % Open a new Figure window. locus (TTT) % Plot the root locus of the conbined system title('ROOTLUCUS FOR THE PID COMPENSATED SYSTEM" ) % Compute root locus of the system with both controllers Ip, k] = mlocus(Tt1); % Desired gain (you can set this value) [Link] = 80; % Find the index of the closest gain to k_desired [x, 6x] = min(abs(k - k desired); % Get the poles associated with the desired gain poles = r(:, idx); % Display the poles for the desired gain disp([‘Poles at k aisp(poles); ", numaste(k_desined), °:°))5 ‘ERROR CALCULATION disp("UNCOMPESATED SYSTEM ERROR") Kpp=dcgain(s); Error_Plant_un=(1/(1+Kpp)) FOR the PD disp("SYSTEM ERROR AFTER PO CONPESATED' ) Kppd=dcgain(TT)3 Error_PO_compasated=(1/(1+Kppd)) XFOR the PID disp("SYTEM ERROR AFTER COMPESATION' ) Kppidedegain(TT2); Error_PID_conpasated=(1/ (1+Kppid)) PID TRANSFER FUNCTION @isp("PID COMPENSATOR TRANSFER FUNCTION’ ) GpidecerGi isp("PID COMPENSATOR TRANSFER FUNCTION IN Z- TRANSFORM" ) PID_Z=c2d(Gpid,13*10%(-6), "tustin’) PLANT TRANSFER FUNCTION 1282+ 205410 Continuous-tine transfer function. PD TRANSFER FUNCTION 6 = sea Continuous-tine transfer function, PT TRANSFER FUNCTION ai = S409 Continuous-tine transfer function. CCOMPESATED TRANSFER FUNCTION m1 = 0.5 542+ 0.95 5 4 0.45, 12 63+ 20 sD 4 10s Continuous-time transfer function. Poles at k = 80: 0.7131 “1.3138 -3.3225, UNCOMPESATED SYSTEM ERROR error_Plant_un = 0.95238 SYSTEM ERROR AFTER PD COMPESATED Error_PO_compasated = 0.95238 SYTEM ERROR AFTER COMPESATION Error_PID_conpasated = PID COMPENSATOR TRANSFER FUNCTION Gpid = S24 1.95409 Continuous-tine transfer function. PTD COMPENSATOR TRANSFER FUNCTION TN 2- TRANSFORM pIoz = 1.838005 292 - 3.07605 2 + 1.53805 22-41 Sample tine: 1.3e-05 seconds Discrete-tine transfer function. Imaginary Axis (seconds”') Imaginary Axis (seconds”') Pole-Zero Map 09 26 07 00 05 04 039 02 01 0 Real Axis (seconds™') ROOTLUCUS FOR THE UNCOMPENSATED SYSTEM 28 0504 02 0 02 Real Axis (seconds”') ROOTLUCUS FOR THE PD COMPENSATED SYSTEM Imaginary Axis (seconds”') 06 2 45 4 05 © oF 1 Real Axis (seconds™') ROOTLUCUS FOR THE PID COMPENSATED SYSTEM ~ ) Imaginary Axis (seconds”') > 35 «3 #25 2 4S 4 05 oO 08 Real Axis (seconds”') Pushed ny MATLAB 2023

You might also like