I want someone to solve this by Matlab and handout for Q1 ,Q3 and Q2 I upload the code so just have it in the lab report .
‘(ch2p1)’ % Display label.
-3.96
% Display scalar number -3.96.
-4 + 7i % Display complex number -4+7i
-5-6j % Display complex number -5-6 j.
(-4+7i)+(-5-6i) % Add two complex numbers and
(-4+7j)*(-5-6j) % Multiply two complex numbers and % display product
M=5 % Assign 5 to M and display.
N=6 % Assign 6 to N and display.
P=M+N % Assign M+N to P and display.
Q=3+4j % Define complex number, Q.
MagQ=abs(Q) % Find magnitude of Q.
ThetaQ=(180/pi)*angle(Q) % Find the angle of Q in degrees.
pause
‘(ch2p2)’ % Display label.
P1= [17-323]
% Store polynomial s^3 + 7s^2 -3s+ % 23 as P1 and display.
pause
‘(ch2p3’ % Display label.
P2 = [3 5 7 8];
% Assign 3s^3 + 5s^2 +7s + 8 to P2 % without displaying.
3*5
% Evaluate 3*5 and display result.
pause
‘(ch2p4)’ % Display label.
P3=poly([-2 -5 -6]) % Store polynomial % (s+2) (s+5)(s+6) as P3 and % display
the coefficients.
pause
‘(ch2p5)’
% Display label.
P4=[5 7 9 -3 2] % Form 5s^4+7s^3+9s^2-3s+2 and % display
rootsP4=roots(P4) % Find roots of 5s^4+7s^3+9s^2 %-3s+2, % assign to rootsP4,
and display.
pause
‘(ch2p6)’ % Display label.
P5=conv([1 7 1 0 9],[1 -3 6 2 1]) % Form (s^3+7s^2+10s+9)(s^4%
3s^3+6s^2+2s+l), assign to P5, % and display.
pause
‘(ch2p7)’ % Display label.
numy=32; % Define numerator.
deny=poly([0 -4 -8]); % Define denominator.
[r, p, k]=residue (numy, deny) % Calculate residues, poles, and % direct
quotient.
pause
‘(ch2p8 Example 2.3’ % Display label.
numy=32; % Define numerator.
deny=poly([0 -4 -8]); % Define denominator.
[r, p, k]=residue (numy, deny) % Calculate residues, poles, and % direct
quotient.
pause
‘(ch2p9)’ % Display label.
‘Vector Method, Polynomial Form’ % Display label.
numf=150*[1 2 7] % Store 150 (s^2+2s+7) in numf and % display.
denf=[1 5 4 0] % Store s (s+1) (s+4) in denf and % display.
‘F(s)’ % Display label.
F=tf (numf, denf) % Form F(s) and display.
clear % Clear previous variables from % workspace.
‘Vector Method, Factored Form’ % Display label.
numg=[-2 -4] % Store (s+2)(s+4) in numg and % display.
deng=[-7 -8 -9] % Store (s+7) (s+8) (s+9) in deng % and display.
K=20 % Define K.
‘G(s)’ % Display label.
G=zpk(numg,deng,K) % Form G(s) and display.
clear % Clear previous variables from % workspace.
‘Rational Expression Method, Polynomial Form’ % Display label.
s=tf (‘s’) % Define ’s’ as an LTI object in % polynomial form.
‘(ch2p10)’ % Display label.
‘Coefficients for F(s)’ % Display label.
numftf=[10 4 0 60] % Form numerator of F (s)= % (10s^2+40s+60)/(s^3+4s^2+5s %
+7).
denftf=[1 4 5 7] % Form denominator of F (s)= % (10s^2+40s+60)/(s^3+4s^2+5s %
+7).
‘Roots for F(s)’ % Display label.
[numfzp,denfzp]=tf2zp (numftf,denftf) % Convert F(s) to factored form.
‘Roots for G(s)’ % Display label.
numgzp=[-2 -4] % Form numerator of
K=10 % G(s)=10(s+2)(s+4)=[s(s + 3) % (s+5)]
dengzp=[0 -3 -5] % Form denominator of % G(s)=10(s+2)(s+4)/[s(s+3)(s+5)].
‘Coefficients for G(s)’ % Display label.
[numgtf, dengtf]=zp2tf (numgzp’, dengzp’, K) % Convert G(s) to polynomial
form.
F=150*(s^2+2*s+7)/[s*(s^2+5*s+4)] % Form F (s) as an LTI transfer % function
in polynomial form.
G=20*(s+2)*(s+4)/[(s+7)*(s+8)*(s+9)] % function in polynomial form.
clear % Clear previous variables from % workspace.
‘Rational Expression Method, Factored Form’ % Display label.
s=zpk(‘s’) % Define ’s’ as an LTI object in % factored form.
F=150*(s^2+2*s+7)/[s*(s^2+5*s+4)]% Form F (s) as an LTI transfer % function
in factored form.
G=20*(s+2)*(s+4)/[(s+7)*(s+8)*(s+9)] % Form G(s) as an LTI transfer %
function in factored form.
pause
‘(ch2p11)’ % Display label.
‘Fzpk1(s)’ % Display label.
Fzpk1=zpk([-2-4],[0-3-5],10) % Form Fzpk1 (s)= % 10(s+2)(s+4)/[s(s+3)(s+5)].
‘Ftf2’ % Display label.
Ftf2=tf([10 40 60],[1 4 5 7] ) % Form Ftf2(s)= % (10s^2+40s+60)/(s^3+4s^2+5s
% +7).
‘Fzpk2’ % Display label.
Fzpk2=zpk(Ftf2) % Convert Ftf2 (s) to % factored form.
pause
‘(ch2p12)’ % Display label.
t=0:0.01:10; % Specify time range and increment.
f1=cos(5*t); % Specify f1 to be cos(5t).
f2=sin(5*t); % Specify f2 to be sin (5t).
plot(t,f1,’r’,t,f2,’g’) % Plot f1 in red and f2 in green.
pause
Control Systems Lab
Experiment #1
ASSIGNMENT
Include the results from the Laboratory Exercise.
1. Complex number exercises. Please work out by hand. You must check your answers with MATLAB.
Let x1=0.1 +0.1j; x2 = 0.1 -0.1j; x3 = -0.1 +0.1j; x4 = -0.1 -0.1j.
a) What are the magnitude and phases of x1, x2, x3 and x4?
b) What is x1 + x2 + x3 + x4?
c) What is xi – X2?
d) What is x3 x4?
e) What is X4/xı?
f) What is {x1/(x2+x3)-x3*x4/x5}*(x2-xl)
g) What is {x2*x3/(x2+x3)-x3*x4/(x5+x1)}*(x3-X2)/(x2-xl)
For all parts please give your answers both in rectangular and polar coordinates. Provide both your hand
calculations and the MATLAB results.
2. Work out all MATLAB examples from the attached handout. The examples are labeled ‘ch2pl’
through ‘ch2p12’. Turn in the examples and their results.
3. Calculate by hand the partial-fraction expansion of the following transfer functions:
5(s+2)
a. G(s) =
s(s2+8s+15)
5(+2)
b. G2(s) =
s(s2 +68+9)
5(8+2)
c. G3(s) =
s(52+68+34)
Use Matlab to compute the partial fraction expansions for parts a through c. Compare the resuts.