Você está na página 1de 8

COMSATS-Lancaster Dual Degree

Programme

Names:-Ali Nawaz Ranjha


Muhammad Anas Younas
Usman Naseer

Registeration # DDP-FA10-BTE-008
DDP-FA10-BTE-030
DDP-FA10-BTE-053

Control Systems Lab


Lab Session 1:-
Q1. Explore magic() command of MATLAB. Try A = magic(5), record your output and
explain.

Q2. Consider two polynomials p ( s)= s2+2s+a and q (s)=s+1. Using MATLAB, find
p(s)*q(s)
Roots of p(s) and q(s)
-1) and q(6)
Write code and record output.

Q3. Use MATLAB to find partial fraction of the following


B(s) /A(s)= 2s3+5s2+3s+6 / s3+6s2+11s+6
B(s) /A(s )=s2+2s+3 / (s+1)3

Q4. Use MATLAB to generate the first 100 terms in the sequence a(n) define recursively
by a(n+1)= P*a(n)* (1-a (n ))
with p=2.9 and a(1) = 0.5.

Q5. Use for or while loop to convert degrees Fahrenheit to degrees Celsius using the
following equation
Tf =9/5 Tc+32
Use any starting temperature, increment and ending temperature (example: starting
temperature=0, increment=10, ending temperature = 200).

Q1(ans.):-

The command magic creates a square matrix which is less


than the square of number entered within the round brackets
of magic command.
Syntax:-

magic(5)

Results:-
ans =

17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9

Q2(ans.):-

a=input('enter the value of a=');


% writing the co-efficients of p in the form
of matrix
p=[1 2 a];
% writing the co-efficients of q in the form
of matrix
q=[0 1 1];
r1=p.*q
r2=roots(p)
r3=roots(q)
% evaluating the above polynomial p at -1
r4=polyval(p,-1)
% evaluating the above polynomial q at 6
r5=polyval(q,6)

Results:-
enter the value of a=1

r1 =
0 2 1

r2 =

-1
-1

r3 =

-1

r4 =

r5 =

Q3(ans.):-

b=[2 5 3 6]
a=[1 6 11 6]
[r,p,k] = residue(b,a)

Results:-

b =
2 5 3 6

a =

1 6 11 6

r =

-6.0000
-4.0000
3.0000

p =

-3.0000
-2.0000
-1.0000

k =

(ii).
b=[1 2 3]
a=[1 3 3 1]
[r,p,k] = residue(b,a)

Results:-
b=

1 2 3

a=
1 3 3 1

r=

1.0000
0.0000
2.0000

p=

-1.0000
-1.0000
-1.0000

k=

[]

Q4(ans.):-

p=2.9;
a(1)=0.5;
for n=1:100
a(n+1)=p.*a(n).*(1-a(n))
end

Results:-
0.5000 0.7250 0.5782 0.7073 0.6004 0.6958 0.6139
0.6874. . . . . . . . . . 0.6552 0.6552 0.6552 0.6552 0.6552

Q5(ans.):-

for Tc = 0:10:200
Tf=9/5.*Tc+32
end

Results:-

Tf =

32

Tf =

50

Tf =

68
.
.
.
.
.

Tf =

356
Tf =

374

Tf =

392

Você também pode gostar