0% found this document useful (0 votes)
26 views

Assignment1 6310610792

The document contains 15 questions related to MATLAB calculations involving vectors, matrices, polynomials, transfer functions, and plotting functions. Various MATLAB commands are used such as roots, poly, tf, zpk, and plot. Calculations include addition, multiplication, differentiation of polynomials, filtering operations, and plotting cosine and sine waves.

Uploaded by

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

Assignment1 6310610792

The document contains 15 questions related to MATLAB calculations involving vectors, matrices, polynomials, transfer functions, and plotting functions. Various MATLAB commands are used such as roots, poly, tf, zpk, and plot. Calculations include addition, multiplication, differentiation of polynomials, filtering operations, and plotting cosine and sine waves.

Uploaded by

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

นายศิวชั ศิรินัย 6310610792

ข้ อ 1
>> 'How are you?'

ans =

'How are you?'

>> -3.96

ans =

-3.9600

>> -4+7i

ans =

-4.0000 + 7.0000i
>> -5-6j

ans =

-5.0000 - 6.0000i

>> (-4+7i)+(-5-6j)

ans =

-9.0000 + 1.0000i
>> (-4+7i)*(-5-6j)

ans =

62.0000 -11.0000i

>> M=5
M=

>> N=6

N=

>> P=M+N

P=

11

>> Q=3+4j

Q=
3.0000 + 4.0000i

>> MagQ=abs(Q)

MagQ =

>> ThetaQ=(180/pi)*angle(Q)

ThetaQ =

53.1301

>> pause

ข้ อ 2
>> P1 = [1 7 -3 23]

P1 =
1 7 -3 23

>> pause
>> P2 = [8 -4 1]

P2 =

8 -4 1

>> P3 = [1 0 0 -1]

P3 =

1 0 0 -1

>>

ข้ อ 3
>> P2 = [3 5 7 8];
>> 3*5

ans =

15

>> 3*5;
>> P2 = [3 5 7 8]

P2 =

3 5 7 8

>>

ข้ อ 4
>> P3 = poly([-2 -5 -6])

P3 =
1 13 52 60

>> syms s
>> (s+2)*(s+5)*(s+6)

ans =

(s + 2)*(s + 5)*(s + 6)

>> expand(ans)

ans =

s^3 + 13*s^2 + 52*s + 60

>> pretty(ans)
3 2
s + 13 s + 52 s + 60

>>
ข้อ 5
>> P4 = [5 7 9 -3 2]

P4 =

5 7 9 -3 2

>> rootsP4 = roots(P4)

rootsP4 =

-0.8951 + 1.2351i
-0.8951 - 1.2351i
0.1951 + 0.3659i
0.1951 - 0.3659i

>>

ข้ อ 6
>> P5 = conv([1 7 10 9],[1 -3 6 2 1])
P5 =

1 4 -5 23 48 81 28 9

>>

ข้ อ 7
>> numf = [7 9 12]

numf =

7 9 12
>> denf = conv(poly([0 -7]),[1 10 100]);
>> [K,p,k] = residue(numf,denf)

K=

0.2554 - 0.3382i
0.2554 + 0.3382i
-0.5280 + 0.0000i
0.0171 + 0.0000i

p=

-5.0000 + 8.6603i
-5.0000 - 8.6603i
-7.0000 + 0.0000i
0.0000 + 0.0000i

k=

[]

>>

ข้ อ 8
>> numf = [1 5 4 0]
numf =

1 5 4 0

>> denf = [1 5 4 0]

denf =

1 5 4 0

>> F = tf(numf, denf)

F=

s^3 + 5 s^2 + 4 s
-----------------
s^3 + 5 s^2 + 4 s

Continuous-time transfer function.


>>

ข้ อ 9
>> numg = [-2 -4]

numg =

-2 -4

>> deng = [-7 -8 -9]

deng =

-7 -8 -9

>> K = 20

K=
20

>> 'G(s)'

ans =

'G(s)'

>> G = zpk(numg, deng,K)

G=

20 (s+2) (s+4)
-----------------
(s+7) (s+8) (s+9)

Continuous-time zero/pole/gain model.

>>
ข้ อ 10
>> s = tf('s')

s=

Continuous-time transfer function.

>> F = 150*(s^2+2*s+7)/(s*(s^2+5*s+4))

F=

150 s^2 + 300 s + 1050


----------------------
s^3 + 5 s^2 + 4 s

Continuous-time transfer function.


>> G = 20*(s+2)*(s+4)/[(s+7)*(s+8)*(s+9)]

G=

20 s^2 + 120 s + 160


--------------------------
s^3 + 24 s^2 + 191 s + 504

Continuous-time transfer function.

>>

ข้ อ 11
>> s = zpk('s')

s=

Continuous-time zero/pole/gain model.


>> F = 150*(s^2+s*2+7)/[s*(s^2+5*s+4)]

F=

150 (s^2 + 2s + 7)
------------------
s (s+1) (s+4)

Continuous-time zero/pole/gain model.

>> G = 20*(s+2)*(s+4)/[(s+7)*(s+8)*(s+9)]

G=

20 (s+2) (s+4)
-----------------
(s+7) (s+8) (s+9)

Continuous-time zero/pole/gain model.


>>

ข้ อ 12
>> numftf = [10 40 60]

numftf =

10 40 60

>> denftf = [1 4 5 7]

denftf =

1 4 5 7

>> 'Roots for F(s)'

ans =
'Roots for F(s)'

>> F = tf(numftf, denftf)

F=

10 s^2 + 40 s + 60
---------------------
s^3 + 4 s^2 + 5 s + 7

Continuous-time transfer function.

>> [numfzp, denfzp] = tf2zp(numftf,denftf)

numfzp =

-2.0000 + 1.4142i
-2.0000 - 1.4142i
denfzp =

-3.1163 + 0.0000i
-0.4418 + 1.4321i
-0.4418 - 1.4321i

>>

ข้ อ 13
>> numgzp =[-2 -4]

numgzp =

-2 -4

>> K = 1=
K = 1=

Incorrect use of '=' operator. Assign a value to a variable
using '=' and compare values for equality using '=='.

>> K = 1

K=

>> dengzp = [0 -3 -5]

dengzp =

0 -3 -5

>> [numgtf, dengtf] = zp2tf(numgzp', dengzp',K)

numgtf =

0 1 6 8
dengtf =

1 8 15 0

>> G = tf(numgtf, dengtf)

G=

s^2 + 6 s + 8
------------------
s^3 + 8 s^2 + 15 s

Continuous-time transfer function.

>>

ข้ อ 14
>> Fzpk1 = zpk([-2 -4],[0 -3 -5],10)
Fzpk1 =

10 (s+2) (s+4)
--------------
s (s+3) (s+5)

Continuous-time zero/pole/gain model.

>> Ftf1 = tf(Fzpk1)

Ftf1 =

10 s^2 + 60 s + 80
------------------
s^3 + 8 s^2 + 15 s

Continuous-time transfer function.

>> Ftf2 = tf([10 40 60],[1 4 5 7])


Ftf2 =

10 s^2 + 40 s + 60
---------------------
s^3 + 4 s^2 + 5 s + 7

Continuous-time transfer function.

>> Fzpk2 = zpk(Ftf2)

Fzpk2 =

10 (s^2 + 4s + 6)
---------------------------------
(s+3.116) (s^2 + 0.8837s + 2.246)

Continuous-time zero/pole/gain model.

>>
ข้ อ 15
>> t= 0:0.01:10;
>> f1 = cos(5*t);
>> f2 = sin(5*t);
>> plot(t,f1,'r',t,f2,'g')
>>

You might also like