You are on page 1of 21

# Matlab

PRESENTED BY : ALI EL -GAZZAR DEMONSTRATOR AT SHOUBRA FACULTY OF ENGINEERING BENHA UNIVERSITY

MATLAB
MATLAB (matrix laboratory)
is a numerical computing environment and fourth-generation programming language. Developed by MathWorks MATLAB allows matrix manipulations, plotting of functions and data, implementation of algorithms

BY: ALI EL-GAZZAR

BY: ALI ELGAZZAR .

Introduction 5^2 or power(5.5) factorial(6) .2) sqrt(25) exp(5) = 𝑒 5 2e5 = 2 x 105 sind(45) sin(45) degree radian = 6! BY: ALI EL-GAZZAR a=3+5j or complex(3.

3 5 7.4] A=[1:10] raw vector column vector B=[1:2:10] C=[10:-1:1] from 1 to 10 with step 2 D=[8 1 5.3.array X=[1 2 3 4] Y=[1.2.4 92] det(D) inv(D) to find the magnitude of matrix to find the inverse of matrix BY: ALI EL-GAZZAR .

1:4*pi y=sin(x) plot(y) grid xlabel('x') ylabel('sin(x)') title('sine function') BY: ALI EL-GAZZAR .2-D plotting x=0:0.

1193 + 1.4218i 0.1.1193 .4218i -0.Polynomial f(s)=𝑠 4 + 2𝑠 3 + 3𝑠 − 5 f=[1 2 0 3 -5] r=roots(f) a=[1 5 8] p=poly(c) find coefficients from the zeros to find the roots r= -2.9170 p= 1 -14 53 -40 BY: ALI EL-GAZZAR .6784 -0.

>> d=[1 2 3 4 8]. >> c=conv(b.d) c= 2 9 20 37 60 74 56 48 BY: ALI EL-GAZZAR .Polynomial multiplication >> b=[2 5 4 6].

4472 0.. ..1803 0 k= [] BY: ALI EL-GAZZAR .F = 𝑎1 𝑠 𝑛 +𝑎2 𝑠 𝑛−1 +.Partial fraction T.0000 p= 16.+𝑎𝑛 𝑠 0 𝑏1 𝑠 𝑚 +𝑏2 𝑠 𝑚−1 +. ....... .. >> d=[1 -10 -100 0].p. >> [r. + 𝑠−𝑝2 𝑠−𝑝𝑛 + 𝑘(𝑠) >> n=[1 10 100].k]=residue(n.... .1803 -6.+𝑏𝑚 𝑠 0 = 𝑟1 𝑠−𝑝1 + 𝑟2 𝑟𝑛 +... .d) r= 1.5528 -1.

4000 D= 0 BY: ALI ELGAZZAR .0000 0 B= 0.4000 -0.8000 1.d). >> sys=tf(n.5000 0 C= 0 0. >> d=[5 7 4].State Space >>n=[1]. >> [A B C D]=ssdata(sys) A= -1.

01:3.Time response num = [25].y) grid title('Unit-Step Response of G(s)=25/(sˆ2+4s+25)') xlabel('t Sec') ylabel('Output') BY: ALI EL-GAZZAR . plot(t.t). t = 0:0.den.t] = step(num.x. [y. den = [1 4 25].

Step response of State Space >> a=[-1 -1.b. >> step(a.d) BY: ALI EL-GAZZAR .0 0]. >> d=[0 0.1 0].1 0].c.0 1]. >> b=[1 1. >> c=[1 0.

Root Locus BY: ALI EL-GAZZAR .

BY: ALI EL-GAZZAR .

d) bode(sys) [gm pm gc pc]=margin(sys) gm = Inf pm = 91.78] d=[.69 1.7302 BY: ALI EL-GAZZAR .4745 gc = NaN pc = 889.9 18.01 .Bode Diagram n=[8.25 1 0] sys=tf(n.

Simulink ...How to run Simulink Type Simulink on command window OR Start . library browser OR Click on Simulink Icon BY: ALI EL-GAZZAR .......

Simulink Sources Continuous Math Operation Sink Step Ramp Transfer Function PID Controller Derivative Integrator State Space Sum Subtract Scope BY: ALI EL-GAZZAR .

PID Controller BY: ALI EL-GAZZAR .

•Drawing the modeling •Run the System •Choose a suitable simulation stop time •Click on the Oscilloscope to show the response of the system •Choose different types Controller •Change the value of each type of controller BY: ALI EL-GAZZAR .

BY: ALI ELGAZZAR BY: ALI EL-GAZZAR .

eg Personal Email : alialgazzar@yahoo.bu.elgazar@feng.For Inquiries Just Contact me Ali Elgazzar Mob: 01119488662 Univ. Email : ali.com BY: ALI ELGAZZAR .edu.