0% found this document useful (0 votes)
9 views20 pages

Control Systems Assignment

The document contains a MATLAB assignment by P. L. P. Ishika, detailing various tasks related to control systems, including matrix operations, solving quadratic equations, plotting functions, and analyzing system responses. It includes code snippets for each task, explanations of the outputs, and instructions for creating specific plots. The assignment also covers step responses for different electrical systems and the use of Simulink for modeling.

Uploaded by

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

Control Systems Assignment

The document contains a MATLAB assignment by P. L. P. Ishika, detailing various tasks related to control systems, including matrix operations, solving quadratic equations, plotting functions, and analyzing system responses. It includes code snippets for each task, explanations of the outputs, and instructions for creating specific plots. The assignment also covers step responses for different electrical systems and the use of Simulink for modeling.

Uploaded by

pedamalluishika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

CONTROL SYSTEMS

ASSIGNMENT
NAME: P. L. P. ISHIKA

ROLL NO: AM.EN.U4ECE23136

1. Define any two 3×3 matrices A and B

 Elements of A:

o Row 1: your age, your mother’s age, your father’s age

o Row 2: first three digits of your pin code

o Row 3: last three digits of your pin code

 B: Random matrix of size 3


CODE:
A = [19, 44, 46;
5, 3, 0;
0, 2, 7];

B = [5, 5, 6;
20, 1, 6;
25, 6, 12];

% (a) Computations
disp('Size of A:');
disp(size(A))
disp('A + B =');
disp(A + B)
disp('A - B =');
disp(A - B)
disp('A / B =');
disp(A / B)
disp('Inverse of A (inv(A)) =');
disp(inv(A))
disp('A + i*B =');
disp(A + 1i*B)
% (b) Matrix multiplications and transpositions
disp('A * B =');
disp(A * B)
disp('Transpose of A (A'') =');
disp(A.')
disp('Transpose of B (B'') =');
disp(B.')
disp('A'' * B'' =');
disp(A.' * B.');
disp('A^2 =');
disp(A^2);
disp('(A'')^2 =');
disp((A.')^2);
% (c) Special matrices
n = 3;
disp('Identity matrix eye(n):');
disp(eye(n));
disp('Zero matrix zeros(n):');
disp(zeros(n));
disp('Ones matrix ones(n):');
disp(ones(n));
disp('Diagonal matrix diag(1:n):');
disp(diag(1:n));
disp('Random matrix rand(n):');
disp(rand(n));

(a) Compute: size(A) ; A + B ; A – B ; A / B ; A \ B ; A⁻¹ ;


A+i*B
OUTPUT:
Explanation:

A / B is equivalent to A * inv(B), which requires B to be non-singular. Since matrix B is nearly


singular (RCOND ≈ 10⁻¹⁸), its inverse is unstable, and thus, the result of A / B may not be
reliable.
(b) Differentiate between: A * B and A * Bᵀ ; A^2 and Aᵀ^2

OUTPUT:

(c) Create the following (n is the size of the matrix):

 Identity matrix — eye(n) ; Matrix of zeros — zeros(n) ; Matrix of


ones — ones(n) ; Diagonal matrix — diag(n) ; Randomly generated
matrix — rand(n)

OUTPUT:
2 . Write a MATLAB program to solve a quadratic equation 𝑎𝑥2 +
𝑏𝑥 + 𝑐 = 0 for any values of a, b and c.

CODE:
a = input('Enter the value of a: ');
b = input('Enter the value of b: ');
c = input('Enter the value of c: ');
if a == 0
disp('This is not a quadratic equation (a = 0).');
else
D = b^2 - 4*a*c ;
fprintf('D = %.2f\n', D);
if D > 0
root1 = (-b + sqrt(D)) / (2*a);
root2 = (-b - sqrt(D)) / (2*a);
fprintf('The roots are real and distinct:\n');
fprintf('Root 1 = %.2f\n', root1);
fprintf('Root 2 = %.2f\n', root2);
elseif D == 0
root = -b / (2*a);
fprintf('The roots are real and equal:\n');
fprintf('Root = %.2f\n', root);
else
realPart = -b / (2*a);
imagPart = sqrt(-D) / (2*a);
fprintf('The roots are complex and imaginary:\n');
fprintf('Root 1 = %.2f + %.2fi\n', realPart, imagPart);
fprintf('Root 2 = %.2f - %.2fi\n', realPart, imagPart);
end
end
OUTPUT:

3. Obtain the output and resulting plots for the following


programs. Obtain the output for the following programs

(i)
CODE:
N = 136 ;
h = pi/N;
x = 0: h: pi ;
y = sin(x) ;
plot(x,y)
text(2, 0.9, 'Name: Ishika', 'FontSize', 11, 'Color', 'black')
text(2, 0.8, 'Roll No: AM.EN.U4ECE23136', 'FontSize', 11,
'Color', 'black')

OUTPUT:

(ii)
CODE:
N = 136;
h = pi/N;
x = 0:h:2*pi;
plot(x, sin(x), 'r-.', x, cos(x), 'g--')
legend('sine', 'cosine');
grid
xlabel('x');
ylabel('functions');
title('Test of multi-plot option in Matlab');
text(2, 0.9, 'Name: Ishika', 'FontSize', 11, 'Color', 'black')
text(2, 0.8, 'Roll No: AM.EN.U4ECE23136', 'FontSize', 11,
'Color', 'black')

OUTPUT:
(iii)
CODE:
N = 136;

h = 2*pi/N;
x = 0:h:2*pi;
subplot(1,2,2);
plot(x, cos(x));
xlabel('x');
ylabel('cosine');
title('Cosine Function');
grid on
subplot(1,2,1);
plot(x, sin(x));
xlabel('x');
ylabel('sine');
title('Sine Function');
grid on
text(4, 0.4, 'Name: Ishika', 'FontSize', 10, 'Color', 'black')
text(4, 0.3, 'Roll No: AM.EN.U4ECE23136', 'FontSize', 10,
'Color', 'black')
OUTPUT:

4. Write a MATLAB programme to plot the half wave rectified sine


wave

CODE:

x = 0 : 0.1 : 3*pi;
y = sin(x);
y_half = y;
y_half(y_half < 0) = 0;
plot(x, y_half, 'r', 'LineWidth', 2);
xlabel('x (radians)')
ylabel('Half-wave rectified sin(x)');
title('Half-Wave Rectified Sine Wave');
grid on;
text(3.5, 0.4, 'Name: Ishika', 'FontSize', 10, 'Color', 'black')
text(3.5, 0.3, 'Roll No: AM.EN.U4ECE23136', 'FontSize', 10, 'Color',
'black')

OUTPUT:
5.

CODE :
zeta = 0.4;
wn = 5;
num = wn^2;
den = [1 2*zeta*wn wn^2];
G = tf(num, den);
figure;
step(G);
title('Unit Step Response of Second Order System (ζ = 0.4, ωn = 5
rad/s)');
xlabel('Time (seconds)');
ylabel('Amplitude');
grid on;
name = 'Ishika';
roll_number = 'AM.EN.U4ECE23136';
text(1, 0.8, ['Name: ' name ', Roll No: ' roll_number], 'FontSize', 12, 'Color',
'blue');

OUTPUT:

6.

CODE:

syms s
num= 25;
den=[1 6 25];
system = tf(num,den) ;
step(system)
stepinfo(system)
title('Step Response');
text(0.8, 0.4, 'Name: Ishika', 'FontSize', 10, 'Color', 'black')
text(0.8, 0.3, 'Roll No: AM.EN.U4ECE23136', 'FontSize', 10, 'Color', 'black')

OUTPUT:
7.

CODE:

syms s
num= 1;
den=[1 0.2 1];
system = tf(num,den) ;
impulse(system)
title('Impulse Response');
name = 'Ishika';
roll_number = 'AM.EN.U4ECE23136';
text(3, 0.8, ['Name: ' name ', Roll No: ' roll_number], 'FontSize',
12, 'Color', 'blue');

OUTPUT:
8. Write a MATLAB program to obtain the step response of the
given electrical system (RLC series circuit). Given R = 1000 ohms,
L =1 H, C= 0.1µF. Determine all the time domain specifications of
the system. Obtain the plots for different damping ratios by
changing the value of R to 200 Ω , 600 Ω, and 1200 Ω ( Plots with
different colours on the same graph sheet). (Hint: Derive the TF
of a RLC series circuit, and substitute the values of R, L and C.
Use step(sys) to obtain the step response of the system. See Help
step in MATLAB)
CODE:

L = 1;
C = 0.0000001;
num = 25;
R_values = [200, 600, 1000 ,1200];
figure;
hold on;
for i = 1:length(R_values)
R = R_values(i);
den = [L*C, R*C, 1];
system = tf(num, den);
[y,t] = step(system);
plot(t, y, 'DisplayName', ['R = ' num2str(R) ' \Omega']);
info = stepinfo(system);
fprintf('Step response characteristics for R = %d Ohms:\n', R);
fprintf(' Rise Time: %f seconds\n', info.RiseTime);
fprintf(' Settling Time: %f seconds\n', info.SettlingTime);
fprintf(' Overshoot: %f%%\n', info.Overshoot);
fprintf(' Peak: %f\n', info.Peak);
fprintf(' Peak Time: %f seconds\n\n', info.PeakTime);
end
legend show;
title('Step Responses for Different R Values');
xlabel('Time (seconds)');
ylabel('Output');
hold off;
text(0.04, 8, 'Name: Ishika', 'FontSize', 10, 'Color', 'black')
text(0.04, 5, 'Roll No: AM.EN.U4ECE23136', 'FontSize', 10, 'Color', 'black')

OUTPUT:
9.
IN MATLAB:

CODE:

num = 1;
den = conv([1 0], conv([0.2 1], [1 1]));
G = tf(num, den);
t = 0:0.01:10;
step(G, t);
title('Step Response using MATLAB');
xlabel('Time (seconds)');
ylabel('Amplitude');
grid on;
text(5, 2, 'Name: Ishika', 'FontSize', 10, 'Color', 'black')
text(5, 1, 'Roll No: AM.EN.U4ECE23136', 'FontSize', 10, 'Color', 'black')

OUTPUT:
IN SIMULINK:

MODEL:

OUTPUT:
10.

IN MATLAB:

CODE:

num_Gc = [50 70];


den_Gc = [1 7];
num_Gp = 1;
den_Gp = conv([1 0], conv([1 1], [1 4]));
Gc = tf(num_Gc, den_Gc);
Gp = tf(num_Gp, den_Gp);
G = series(Gc, Gp);
T = feedback(G, 1);
step(T, 0:0.01:10);
title('Step Response of the Closed-Loop System');
grid on;
info = stepinfo(T);
disp('Time Domain Specifications:');
disp(info);
text(4.5, 0.8, 'Name: Ishika', 'FontSize', 10, 'Color', 'black')
text(4.5, 0.6, 'Roll No: AM.EN.U4ECE23136', 'FontSize', 10, 'Color', 'black')

OUTPUT:
IN SIMULINK:

MODEL:

OUTPUT:

You might also like