Matlab Basic Tutor

15
Matlab Basic

Transcript of Matlab Basic Tutor

Page 1: Matlab Basic Tutor

Matlab Basic

Page 2: Matlab Basic Tutor

Topic• Introduction Matlab• Matrix Manipulation• Signal Generate• Fourier Theorem• Matlab Concept• PSCAD to Matlab• Conclusion

Page 3: Matlab Basic Tutor

> Introduction> Matrix> Signal Gen.> Fourier Theorem> Matlab Concept> PSCAD To Matlab> Conclusion

Topic

Menu bar

Workspace

Command historyCommand windown

Page 4: Matlab Basic Tutor

> Introduction> Matrix> Signal Gen.> Fourier Theorem> Matlab Concept> PSCAD To Matlab> Conclusion

Topic

Name OperatorMatlab

Operator

Addition + A+B

Subtraction - A-B

Multiplication * A*B

Division / A/B

Array right division

./ A./B

Matrix left division

\ A\B, A*inv(B)

Array left division .\ A.\B

Matrix power ^ A^b

Arithmetic Operators

Page 5: Matlab Basic Tutor

> Introduction> Matrix> Signal Gen.> Fourier Theorem> Matlab Concept> PSCAD To Matlab> Conclusion

Topic

Name OperatorMatlab

Operator

Less < X < 10

Less than or equal <= X <= 10

Greater > X > 10

Greater than or equal

>= X >= 10

Equal == X == 1

Not Equal ~= X ~= 5

And & X > 2 & y < 1

Or | X > 2 | y < 1

Not ~ ~x

Relational & Logic Operators

Page 6: Matlab Basic Tutor

> Introduction> Matrix> Signal Gen.> Fourier Theorem> Matlab Concept> PSCAD To Matlab> Conclusion

Topic

Name Matlab

sin sin(x)

cos cos(x)

tan tan(x)

arc sin asin(x)

arc cos acos (x)

arc tan atan(x)

Relational & Logic Operators

Page 7: Matlab Basic Tutor

> Introduction> Matrix> Signal Gen.> Fourier Theorem> Matlab Concept> PSCAD To Matlab> Conclusion

Topica = [1 2 3]

a = [1 2 3;4 5 6;7 8 9]

1 2 34 5 67 8 9

1 2 3

a’ = ?

1 4 72 5 83 6 9

Page 8: Matlab Basic Tutor

> Introduction> Matrix> Signal Gen.> Fourier Theorem> Matlab Concept> PSCAD To Matlab> Conclusion

Topicb = a(3,2)

8

b = a(1:2, 1:2)

1 24 5

b = a(1:2, 1:2)

5 68 9

Page 9: Matlab Basic Tutor

> Introduction> Matrix> Signal Gen.> Fourier Theorem> Matlab Concept> PSCAD To Matlab> Conclusion

Topic1 2 34 5 67 8 9

1 37 9 = ? A(1:2:3,1:2:3)

1 34 6= ? A(1:2,1:2:3)

Page 10: Matlab Basic Tutor

> Introduction> Matrix> Signal Gen.> Fourier Theorem> Matlab Concept> PSCAD To Matlab> Conclusion

Topic1 2 34 5 67 8 9

a =

b =

9 8 76 5 43 2 1

a*b =

30 24 1884 69 54138 114 90

a.*b =

9 16 2124 25 2421 16 9

Page 11: Matlab Basic Tutor

> Introduction> Matrix> Signal Gen.> Fourier Theorem> Matlab Concept> PSCAD To Matlab> Conclusion

Topic

0 1 1 2 2( ) cos( ) cos(2 ) ... cos( )n nf t A A t A t A n t

t = 0:0.000625:0.1;

w = 2*pi*50;

ft = 3*cos(w*t);

plot(t, ft, ‘r’)

Page 12: Matlab Basic Tutor

> Introduction> Matrix> Signal Gen.> Fourier Theorem> Matlab Concept> PSCAD To Matlab> Conclusion

Topic

ft = 12+72cos(wt)+64cos(2wt)+25cos(7wt)+46cos(9wt)

Page 13: Matlab Basic Tutor

> Introduction> Matrix> Signal Gen.> Fourier Theorem> Matlab Concept> PSCAD To Matlab> Conclusion

Topic

0 1 1 2 2( ) cos( ) cos(2 ) ... cos( )n nf t A A t A t A n t

01

( ) ( cos sin )n nn

f t a a n t b n t

0

0

1( )

T

a f t dtT

0

2( )cos

T

na f t n tdtT

0

2( )sin

T

nb f t n tdtT

2 2n n nA a b ∅=atan (

𝑏𝑛

𝑎𝑛

)

Page 14: Matlab Basic Tutor

> Introduction> Matrix> Signal Gen.> Fourier Theorem> Matlab Concept> PSCAD To Matlab> Conclusion

Topic

t=0.02/128:0.00015625:0.02;w = 2*pi*50;ft =12+72*sin(w*t +)+53*sin(3*w*t+)+37*sin(5*w*t+);x1 = cos(w*t);x2 = sin(w*t);a1 = (2*sum(ft.*x1))/128;b1 = (2*sum(ft.*x2))/128;A = sqrt(a1^2+b1^2) Arms = A/sqrt(2)

Fourier code

Page 15: Matlab Basic Tutor

> Introduction> Matrix> Signal Gen.> Fourier Theorem> Matlab Concept> PSCAD To Matlab> Conclusion

Topic