0% found this document useful (0 votes)
22 views3 pages

Matlab Lab Report

This report demonstrates the use of MATLAB for solving fundamental math and programming problems, including matrix operations, vector calculations, and polynomial manipulation. It covers exercises such as extracting rows from matrices, performing vector arithmetic, plotting sine and cosine curves, and conducting polynomial operations. Additionally, it includes examples of partial fraction decomposition for given polynomials.

Uploaded by

moxesora
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)
22 views3 pages

Matlab Lab Report

This report demonstrates the use of MATLAB for solving fundamental math and programming problems, including matrix operations, vector calculations, and polynomial manipulation. It covers exercises such as extracting rows from matrices, performing vector arithmetic, plotting sine and cosine curves, and conducting polynomial operations. Additionally, it includes examples of partial fraction decomposition for given polynomials.

Uploaded by

moxesora
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

COMPUTER

ENGINEERING
University of Tripoli
Faculty of Engineering

Department of Computer Engineering

Control Systems Lab – EC446L

Lab #1-Using MATLAB for Control Systems


Salah Ismail Al-Madhoun – 2200208589
Instructor: D. Dakhil Al-Jarwali
Group 2
Introduction
This report shows how MATLAB can be used to solve basic math and
programming problems. It includes matrix operations, vector calculations,
plotting graphs, working with polynomials, and breaking down fractions.

Exercise 1
a) Extract the Fourth Row from magic(6)
A = magic(6);
row4 = A(4, :)

b) Multiply and Divide Two Vectors


x = 0:0.1:1.1; % 12 elements
y = 10:21; % 12 elements

product = x .* y;
division = y ./ x;

disp('x .* y =');
disp(product);

disp('y ./ x =');
disp(division);

c) Generate Random Matrix r of Size 4×5 with Values between -8 and 9


r = randi([-8, 9], 4, 5);
disp('Random matrix r =');
disp(r);

Exercise 2
Plot Sin and Cos Curves in Subplots
x = pi/2 : pi/10 : 2*pi;
y = sin(x);
z = cos(x);

subplot(2,1,1);
plot(x, y, 'b+:');
title('Sin Curve');
xlabel('Angle');
ylabel('Sin(x)');
legend('Sin');
grid on;

subplot(2,1,2);
plot(x, z, 'r*--');
title('Cos Curve');
xlabel('Angle');
ylabel('Cos(x)');
legend('Cos');
grid on;

Exercise 3: Polynomial Operations


Given Polynomials:
p(s) = s^2 + 2s + 1
q(s) = s + 1

p = [1 2 1];
q = [1 1];

a) Multiply p(s) * q(s)


product = conv(p, q)

b) Roots of p(s) and q(s)


roots_p = roots(p)
roots_q = roots(q)

c) Evaluate p(-1) and q(6)


val_p_neg1 = polyval(p, -1)
val_q_6 = polyval(q, 6)

Exercise 4: Partial Fraction Decomposition


a) (2s^3 + 5s^2 + 3s + 6) / (s^3 + 6s^2 + 11s + 6)
num = [2 5 3 6];
den = [1 6 11 6];
[r, p, k] = residue(num, den)

b) (s^2 + 2s + 3) / ((s + 1)^3)


num = [1 2 3];
den = [1 3 3 1]; % (s + 1)^3 expanded
[r, p, k] = residue(num, den)

You might also like