Lab 1 Introduction To Matlab
Lab 1 Introduction To Matlab
visualization and programming in an easy to use environment where problems and solutions are expressed in familiar mathematical notation Typical uses include Math and computation Algorithm development Data acquisition Modeling, simulation and prototyping Data analysis, exploration and visualization Scientific and engineering graphics Matlab basics In matlab commands are input in the matlab command window. It returns the output in two ways. Typically, test or numerical output is returned in the same command window and graphical output appears in a separate graphics window.
We can do arithmetic in matlab >> d=4+5i d = 4.0000 + 5.0000i To find modulus >> sqrt(d*conj(d)) 1
ans = 6.4031
Separating real part >> real_d=real(d) real_d =4 Separating imaginary part >> imag_d=imag(d) imag_d =5 To find angle in radians atan_d=atan(imag_d/real_d) atan_d =0.8961 Defining a matrix >> A=[7 8 -5;3 -4 0] A= 7 3 8 -5 -4 0
Laplace Transform L=Laplace(F) is the Laplace transform of the scalar symbol F with default independent variable t. The default return is a function of s. The Laplace transform is applied to a function of t and returns a function of s. Q1: Find the Laplace transform of >> syms s a t >> td=exp(-a*t) >> laplace(td) ans = 1/(s+a) Inverse Laplace Transform Inverse Laplace transform is used to convert the function from s domain to the time domain. Q2: Find the Inverse Laplace of 1/(s+a) >> syms a s t >> k=1/(s+a) >> ilaplace(k) ans = exp(-a*t)
Q3: Convert the polynomial F(s)=(10s^2+40s+60)/(s^3+4s^2+5s+7) to its roots and then from its roots back to the polynomial >> num1=[10 40 60]; >> num2=[1 4 5 7]; >> tf(num1,num2)
Transfer function: 10 s^2 + 40 s + 60 --------------------s^3 + 4 s^2 + 5 s + 7 >> r1=roots(num1) r1 = -2.0000 + 1.4142i -2.0000 - 1.4142i >> r2=roots(num2) r2 = -3.1163 -0.4418 + 1.4321i -0.4418 - 1.4321i >> p1=poly(r1) p1 = 1.0000 4.0000 6.0000 >> p2=poly(r2) p2 = 1.0000 4.0000 5.0000 7.0000 Q4: Convert the polynomial s(s+3) / (s+6)(s+9)(s+7) into its partial fraction and find its inverse laplace transform and then from its partial fraction back to the polynomial coefficients >> num1=conv([1 0],[1 3]); >> num2=conv([1 6],conv([1 9],[1 7])); >> [r p k]=residue(num1,num2) r= 9.0000 -14.0000 6.0000 3
p= -9.0000 -7.0000 -6.0000 k= [] >> a=9/(s-9); >> b=-14/(s-7); >> c=6/(s-6); >> d=a+b+c d= 9/(s-9)-14/(s-7)+6/(s-6)
>> pretty(d) 9 14 6 ----- - ----- + ----s-9 s-7 s-6 >> ilaplace(d) ans = 9*exp(9*t)-14*exp(7*t)+6*exp(6*t)
Lab Tasks: Find the Laplace transform of f(t)= -1.25+3.5t command and then display using pretty command. Also find the inverse Laplace of F(s)= (s-5) / s 4 +1.25 .Also simplify the answer using simplify(function)