This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: An introduction to MATLAB MATLAB is an important software package in engineering and is widely available. Most plots in Signals and Systems , 3/e, were generated using MATLAB. We give a brief intro- duction of MATLAB to the extent that the reader could generate most plots in Chapter 1 of the aforementioned book. MATLAB runs on a number of windows. The window which appears when we start MATLAB is called the command window . It is the primary window where we interact with MATLAB. A sequence of numbers, such as -0.6, -0.3, 0, 0.3, 0.6, 0.9, 6/5, can be expressed in MATLAB as a row vector as >> t=[-0.6 -0.3 0 0.3 0.6 0.9 6/5] where >> is a command prompt. If we type “enter” at the end of the line, MATLAB will execute and store it in memory, and then display it on the monitor as t= -0.6000 -0.3000 0 0.3000 0.6000 0.9000 1.2000 From now on, it is understood that every line will be followed by “enter”. If we type >> t=[-0.6 -0.3 0 0.3 0.6 0.9 1.2]; then MATLAB will execute and store it in memory but will not display it on the monitor. In other words, the semicolon at the end of a statement suppresses the display. Note that we have name the sequence t for later use. The MATLAB function a:b:c generates a sequence of numbers starting from a with increment b up to or less than c . For example,-0.6:0.3:1.2 generates the sequence t . If b is missing, then the increment is 1 by default. For example,-0.6:1.2 yields [-0.6 0.4] and n=-2:4 yields [-2 -1 0 1 2 3 4] . Using n , the sequence t can also be generated as t=0.3*n or t=n*0.3 . Suppose we want to compute the values of z ( t ) = 2 e- . 3 t sin 4 t at those t . Typing >> t=-0.6:0.3:1.2; >> z=2*exp(-0.3*t).*sin(4*t) will yield z =- 1 . 6174- 2 . 0396 0 1 . 7036 1 . 1284- . 6756- 1 . 3900 These are the values of z ( t ) at those t. We mention that the variable z consists of seven entries. MATLAB automatically assigns the entries by z(k), with k=1:7. We call the integer k the internal index . Internal indices start from 1 and cannot be zero or negative. If we continue to type >> z(2) then it will yield -2.0396. If we type z(0) or z(8), then an error message will appear because the internal index is zero or outside the range. Typingthe internal index is zero or outside the range....
View Full Document
This note was uploaded on 02/24/2010 for the course ESE 337 taught by Professor Chi-tsongchen during the Fall '10 term at SUNY Stony Brook.
- Fall '10