lab program
lab program
CODE:
% Define the transfer functions for the blocks
G1 = tf([1], [1 1]); % Example transfer function for G1 (numerator: 1, denominator: s+1)
G2 = tf([2], [1 2]); % Example transfer function for G2 (numerator: 2, denominator: s+2)
H = tf([1], [1 3]); % Example transfer function for H (numerator: 1, denominator: s+3)
OUTPUT:
PROGRAM 02: Implement Signal Flow graph to obtain
transfer function a control system.
CODE:
function T = masons_gain(nodes, forward_paths, loops)
% Mason's Gain Formula to find transfer function from a signal flow graph
% nodes - total number of nodes
% forward_paths - cell array of forward paths and their gains
% loops - cell array of loops and their gains
% Calculate Delta
delta = 1 - sum(cellfun(@(x) x{2}, loops));
% Example usage:
% Define the nodes (This is illustrative, nodes are typically implied in paths and loops)
nodes = 4;
CODE:
% Define the numerator and denominator of the transfer function
num = [1 3 5]; % Example numerator coefficients
den = [1 2 3 4]; % Example denominator coefficients
OUTPUT:
PROGRAM 04: Implement time response specification of a
second order Under damped System, for different
damping factors.
CODE:
% Define parameters
zeta = 0.5; % Damping factor
omega_n = 5; % Natural frequency
figure;
plot(t, y, 'LineWidth', 2);
title('Step Response of a Second-Order Underdamped System');
xlabel('Time (seconds)');
ylabel('Response');
grid on;
OUTPUT:
PROGRAM 05: Implement frequency response of a second
order System.
CODE:
% Parameters for the second-order system
% Define the natural frequency (omega_n) and damping ratio (zeta)
omega_n = 10; % Natural frequency (rad/s)
zeta = 0.5; % Damping ratio
CODE:
% Lead-lag compensator parameters
% Adjust these parameters as needed
K = 1; % Gain
alpha = 0.1; % Lead compensator zero/pole ratio
beta = 10; % Lag compensator zero/pole ratio
T1 = 0.1; % Time constant of the lead compensator
T2 = 1; % Time constant of the lag compensator
OUTPUT:
PROGRAM 07: Analyze the stability of the given system
using Routh stability criterion.
CODE:
function routh_stability(coefficients)
% coefficients: Vector of the coefficients of the characteristic polynomial
% Example: coefficients = [1 3 5 6] for the polynomial s^3 + 3s^2 + 5s + 6
n = length(coefficients);
routh_table = zeros(n, ceil(n/2));
if sign_changes == 0
disp('The system is stable.');
else
disp(['The system is unstable with ', num2str(sign_changes), ' poles in the right half-
plane.']);
end
end
% Example usage
coefficients = [1 3 5 6]; % Define the coefficients of your system's characteristic polynomial
routh_stability(coefficients);
OUTPUT: