In the name of Allah Chapter 1 Before beginning the computer exercises, some of the fundamental tools Used to construct signals in MATLAB is covered here. You can use the MATLAB user’s guide as the best help to continue. Matrix: >> A = [1, 2; 3, 4]; A = 1 3 2 4 ☺ try to see the effect of character ‘; ‘at end of the command. It is used for preventing echo. >> A (2, 1) ans = 3 >> A’ ans = 1 2 3 4 >> det( A ) ans = -2 ☺ see “ inv( A )” . >> B = zeros (2, 4) B= 0 0 0 0 ☺ see “ones (n, m)”. 0 0 0 0 >> C = [A, B] C= 1 3 2 4 0 0 0 0 0 0 0 0 -2 -1 0 1 2 3 -1.8 … 1.8 1.9 2 >> C = [-3: 3] C= -3 >> C = [-2: 0.1: 2] C= -2 -1.9 >> A (: 2) ans = 2 4 >> A (1, : ) ans = 1 2 >> A * A ans = 7 15 10 22 >> A .* A ans = 1 9 4 16 ☺ “A * A “ and “A .* A “ are different !! See ‘Arithmetic Operations’ in index part of HELP. >> C = [pi / 3, pi] >> Sin(C) ans = 0.86603 1.2246e-6 ≈ 0 Some other functions and commands available: >> clc use help ! >> clear >>A = [-10: 10]; >> B = sin (2 * pi / 20 * [1: 21]); >>stem (A, B) See result! >> plot (A, B) >> title ( ' this is title ' ) >> xlabel( ' this is x label ' ) >> ylabel( ' this is y label ' ) See result ! ☺ also see subplot command. ☺ Note that you can save these Figures. >> x = sym( 'sin( w * t ) ' ) This is a symbolic expression with two variables. Many functions exist which are used with symbolic expressions. x = sin( w * t ) >> x = subs( x, ' w ', 4 ) x = sin( 4 * t ) >> int ( x ) ans = -1/4 * cos( 4 * x ) this is indefinite integral. ☺ see int and diff functions. ☺ see the useful function : ezplot( x, [ min, max ] ) . [ min, max] is the domain interval. ezplot( x, [ 1, 10 ] ) Here we have some other functions, I recommend you to read the primer. PDF file in homepage. abs absolute value or complex magnitude angle(phase) phase angle sqrt square root real real part imag imaginary part conj complex conjugate gcd greatest common divisor lcm least common multiple round round to nearest integer fix round toward zero floor round toward -∞ ceil round toward ∞ sign signum function rem remainder exp exponential base e log natural logarithm log10 log base 10 sin, asin, sinh, asinh cos, acos, cosh, acosh tan, atan, atan2, tanh, atanh cot, acot, coth, acoth sec, asec, sech, asech csc, acsc, csch, acsch semilogx semilogy Polynomial: residue roots poly polyval polyvalm polyfit conv plot data as logarithmic scales Convert between partial fraction expansion and polynomial coefficients Polynomial roots Polynomial with specified roots Polynomial evaluation Polynomial curve fitting Convolution and polynomial multiplication Matrix: linspace cumsum cumprod diag length Cumulative sum Cumulative production Computer exercises: 1- Transformation of the Time Index for Discrete-Time Signals. x[ n ] = 2 n = 0, 1 n = 2, -1 n = 3, 3 n =4, 0 otherwise. Represent the following discrete signals : x[ n - 2 ], x[ n + 1 ], x[ - n ] , x[ - n + 1 ]. Use stem command for discrete functions. 2- Properties of Discrete-Time Signals. Construct a counter-example using MATLAB to demonstrate if the system violate the properties: linearity, time invariance , stability, causality, invertibility. y[ n ] = x ³[ n ] y[ n ] = n x [ n ] y[ n ] = x[ 2n ] 3- Transformation of the Time Index for Continuous-Time Signals. first create an mfile called Heaviside.m in your working directory. The contents of the file are as follow: function myf = Heaviside( t ) myf = ( t >= 0 ); now we have f( t ) = t ( U( t ) - U( t – 2 ) ) use ezplot to plot the following functions: g1( t ) = f( - t ) g2 ( t ) = f( t + 1 ) g3 ( t ) = f( t – 3 ) g4 ( t ) = f( - t + 1 ) g5 ( t ) = f( -2t + 1 ) [email protected]
© Copyright 2024 Paperzz