1250 Homework Matlab® 2 S 14 QOD: Put sticky note in your MATLAB® textbook for the tables in the "Summary" at the end of Chapter 3. What are the ways to create arrays and extract pieces of arrays? 1. MATLAB® can generate random numbers that look like the noise observed in all electrical signals and heard in musical recordings, as the following steps demonstrate. a) Use the randn() function in MATLAB® to create a 1 by 2000 vector of noise samples. b) Use the sound() function in MATLAB® to listen to the vector of noise samples. Describe the sound you hear. Remember that you can write Matlab® statements that are comments if you start with a % symbol. c) 2. Use the plot() function in MATLAB® to see your waveform of noise samples. Describe the pattern of the waveform. Problem 3.1 of the Ulably and Maharbiz text (used by permission of the publisher) has the following node-voltage equation: 16 12 + 2 6 V= 1 1 1 + + 2 3 6 Use MATLAB® to compute V. 3. Problem 3.15 of the Ulably and Maharbiz text has the following circuit and nodevoltage equations: V1 V V -V - 2 + 2 + 2 3 = 0A 0.5 W 0.5 W 0.5 W V2 - V1 = 6V V3 - V2 - 4A+ 2A = 0A 0.5 W MATLAB® can solve these equations if we transform them into a matrix equation. The first step is to write the equations in the following constant current, I's, on the right: é g11 g12 V1g11 + V2 g12 + V3g13 = I1 ê V1g21 + V2 g22 + V3g23 = I 2 or ê g21 g22 ê g V1g31 + V2 g32 + V3g33 = I 3 g ë 31 32 form with V's on the left and g13 ù é V1 ù é I1 ù úê ú ê ú g23 ú ê V2 ú = ê I 2 ú g33 ú ê V3 ú ê I 3 ú ûë û ë û Recall that the product of matrices (and vectors are just matrices with only one row or column) is calculated by taking a dot product of the rows of the left matrix and the column(s) of the right matrix. For this problem 3.15, we have the following equations from which we can identify g's and I's: 1 ö æ 1 ö æ 1 æ -1 ö V1 ç + V2 ç + + V3 ç = 2A ÷ ÷ è 0.5 ø è 0.5 0.5 ø è 0.5 ÷ø V1(-1) + V2 (1) +V3(0) = 6V (not currents, but we could divide all by 1Ω) æ -1 ö æ 1 ö V1(0) + V2 ç + V3 ç = 2A ÷ è 0.5 ø è 0.5 ÷ø We have the following matrix equation. é æ 1 ö æ 1 1 ö ê ç + ÷ ç ÷ ê è 0.5 W ø è 0.5 W 0.5 W ø ê -1 1 ê 1W 1W ê ê æ -1 ö 0 ê çè 0.5 W ÷ø ê 1W ë æ -1 ö ù çè 0.5 W ÷ø ú é 2A ù úé ù V ú úê 1 ú ê 0 6V ê ú ú ê V2 ú = ê 1W 1W ú úê ú ê ú ú V3 û æ 1 ö úë êë 2 A úû çè 0.5 W ÷ø ú û Note that we can use MATLAB® to compute sums to get the gij values. That is, we need only simply the equations to a limited extent. Now we are ready to use MATLAB®. a) Create a matrix (call it what you like) in MATLAB® containing the values of the g's. b) Create a vector (call it what you like) in MATLAB® containing the values of the I's. c) Use the inv() function in MATLAB® to invert the matrix of g's, and then multiply the result by the vector of I's to get the vector of V's. Verify that you get the following answer: V1 = -2V, V2 = 4V, V3 = 5V 4. The equation for a diode's current versus voltage is exponential: ( ) i = I 0 ev/vT -1 where I0 = 20 pA is a constant, vT ≈ 26 mV is a constant, v is the voltage drop across the diode, and i is the current through the diode. a) Using MATLAB®, find the current in the diode when the voltage across it is 0.7 V. b) Using MATLAB®, find the current in the diode for at least three (more is better) voltages across the diode. Create a vector of the v values (you choose the name for the vector) and create another vector of i values (again, you choose the name for the vector). Use the plot command in Matlab® to make a plot of i versus v for the diode. (Note: the syntax for the plot command for vectors x and y would be plot(x,y)).
© Copyright 2025 Paperzz