SPRING 2000 LAB # 10 F. A. Q. “Numerical Evaluation of Fourier Series” NOTE: There are two parts in this set of FAQs. The first part is related to Fourier series. However, this part is based on the SYMBOLIC toolbox in MATLAB. The second part is related to lab#10 “Design with Fourier Series”.
0. Some of these questions don’t seem to make sense with respect to this semester’s lab.
ANSWER: Correct. The FAQs are based on the labs from Fall-99. Refer to that lab description when certain section numbers are cited.
__________________________________________________
PART I: Fourier series
1. For the range -2*pi*400 to 2*pi*400, can we assume that this is just as it reads and not omegahat? (i.e., -800pi to 800pi)
ANSWER: This is ANALOG frequency: omega, not omega-hat. In general, omega runs from -infinity to +infinity. The range -400 Hz to +400 Hz is chosen because the input frequency is 120 Hz and we want to see what the filter does to the input frequency and its first few harmonics
2. I solved by hand for H(jw) using the formula H(jw) = integral from -infinity to +infinity (h(t)e^-jwt dt) . For the required MATLAB function, are we not supposed to use the symbolic toolbox? Could I simply show my hand calculations, and write MATLAB code that plots my solved H(jw)?
ANSWER: YES, you can do it by hand if you don’t have the symbolic toolbox. Doing the Fourier Series of the “full-wave rectified cosine” will be the hardest integral. Check your answer(s) using MATLAB.
3. The output vector, of the integral, I got from MATLAB contains very complex looking expressions. Imaginary j’s and omegas are strewn about liberally, as well as something called “signum”, for which I can find no help() file.
ANSWER: Signum(x) is the sign of “x” so it is +1 for positive x, and -1 for negative x, and zero for x=0. What did you get in the warm-up section 3.5? What signal was being treated there? This integral should be nearly the same. Also, did you apply the simple() function? Simple() is a function that simplifies “hairy” algebraic expressions. One unfortunate feature of symbolic algebra programs is that they produce very strange looking formulas when doing integrals, because they apply their rules in a very methodical order (unlike human beings who do integrals with “insight”, at least when we do them correctly).
4. Is it accurate to say that the absolute value function can be taken care of with the appropriate limits and period based on the frequency as affected by the abs() operator? Or is it imperative to actually take the absolute value of the signal instead, with the standard limits, etc?
ANSWER: YES, your first statement is correct, and it also helps you to get the fundamental period correct. You want to avoid putting the abs() inside the integral.
MAPLE probably can’t find a rule for integrating abs().
5. I’ve tried using ezplot(), and got the following error:
???Function ‘atan2’ not defined for variables of class ‘sym’
If I use plot(), then I would have to consider discrete values of omega, which doesn’t seem like the right thing to do for an analog system.
ANSWER: Discrete values are OK. How else can you make a plot of a continuous function in MATLAB? Recall that to plot a continuous signal in MATLAB, we need to discritize the signal since the computer deals with discrete data only. To get a graph that is very close to the continuous one, we need to choose a very small distance between the samples (i.e. Ts->0).
6. I am running the program based on parameters for the absolute value of the signal v(t), i.e., x(t), but am getting a graph that does not reflect absolute value? It should, should it not, look just like the graph that would be obtained by directly taking the absolute value of v(t)?
ANSWER: Adding up a few of the Fourier Series terms should give something close to abs(cos). Similar to the warm-up, where the waveform was a half-wave rectified sine. The more Fourier Series terms you add, the closer the signal you obtain to the real signal.
7. What does this error mean when I plot?
??? Error using ==> plot Ambiguous line property: ‘s’.
ANSWER: Somehow you are passing a string into plot(). Check the variable types that you are passing. When using the symbolic toolbox, you might end up passing a symbolicexpression instead of a numerical vector.
8. The fundamental period of the rectified signal is double the period of the input signal (from lab 10), but how do we prove this mathematically? Also, do we have to do the symbolic integral for the frequency response, since we already have the answer of the integral from part (a)?
ANSWER: “Prove” it from the plot. No symbolic integral is needed for the frequency response. Additionally, the fundamental period of the rectified signal is half of the period of the original signal; the rectifier doubles the frequency and halves the period.
9. My graph of the magnitude of H(jw) cuts off frequencies close to zero, or in other words, anything above 0.035. Can anyone tell me why? My maximum magnitude is still higher than this and is located close to zero (it may actually be zero).
ANSWER: Sounds like it might be correct. *Remember you want to eliminate all ripple, so you should be filtering out all the sinusoidal terms except for D.C. If you have H(jw) = b/(a+jw), then there are 3 points of easy evaluation (check these for your case):
at w=0, H(j0) = b/a
at w = infinity, H —> 0
at w = a, you get H(ja) = b/(a+ja), so mag = 0.707*(b/a), which is 0.707 times the magnitude at D.C. Phase is -pi/4. For first-order analog filters, the “w = a” point is regarded as the cut-off frequency to define the width of the passband of the LPF.
10. How long should our expression for ak be?
ANSWER: If Maple/MATLAB produces a rather complicated expression, use simple() to have Maple do a reduction. The final formula is fairly compact if you combine the complex conjugate terms together.
11. It says to use T0 equal to the fundamental period of the rectified signal x(t). I believe that is equal to half the period for v(t). But when all of the plots are made, and in 4.2(b) when y10(t) is plotted, it gives a straight line, instead of the sinusoid that was given in Lab #10. Is this the period we are supposed to use? Or are we supposed to use the one for v(t)? Or are they the same?
ANSWER: You can measure the period from the plot of v(t). If you are getting a “straight line” then I suspect that the harmonics are not being added in. OR, the filter is removing all the harmonics. How big were the bk’s in part 4.2(a)?
Here is a THEOREM:
If the input to a LTI system is periodic with fundamental period T0, then the output will also be periodic with the same period (although T0 may not be the fundamental period for the output).
Proof: substitute into the convolution integral and do a change of variables.
Example: sinusoid in gives sinusoid out.
12. I’ve tried computing H(jw) by hand and with the toolbox, both to no avail. I never end up with a solution in the form of H(jw) = Beta/(jw*alpha). I am computing the integral for -infitiy to infinity of the given h(t)*e^-jwt. Is this the correct integral?
ANSWER: Read the notes. This is the very first thing done in Chapter 12. It is the most basic FT pair that we have.
13. Should the magnitudes of the components of the stemplot (derived from the ak’s
evaluated for k = -3 to +3 according to the formula obtained) be the same or nearly the same as the amplitude of the input signal? In other words, at the value of zero, should both v(t) and x(t) have the same absolute value?
ANSWER: Probably not. At k=0, you have D.C., and x(t) has a non-zero D.C. value, but v(t) has a zero D.C. component. So, a1 should be somewhat smaller than the amplitude of v(t).
14. I am having difficulty getting the ak’s for this part. When I did it w/ the symbolic toolkit in lab two weeks ago, I must’ve done it wrong, because the simplified formula it gave me is comprised of exponents and is extremely long, none of which can be combined into sines or cosines. I’ve tried integrating it by hand, using the steps shown for Parseval’s Theorem in Chapter 11 on page 1124, but I end up with something that has k in the denominator. This means that for k=0, my ak is undefined, which I’m sure is incorrect. Should the formula for the ak’s look something like a sum of sinc functions? What, roughly, should the plots for x10(t) and y10(t) look like? I imagine that y10(t) should look something like our filtered signal from Lab 10?
ANSWER: The ak’s should look something like the ones obtained in the warm-up for the “half-wave rectified” sinusoid, section 3.5. Not really a sum of sinc’s. Note that x10(t) is approximating the “rectified cosine” so it should look a lot like x(t) = |v(t)|; y10(t) should look like the STEADY-STATE part of your solution to Lab #10. You will get “k” in the denom. Like the sinc() function. Make sure that you have the minimum period of x(t) for T0, look at 3.5 in the warm-up. You should be able to modify that code. The big difference is that you have a different period.
15. I want to find the Fourier Series of x(t). Which fundamental period do I use for part(c)? The one given for v(t) or the one that we found in part(b) for x(t)?
ANSWER: The one for x(t) because you are finding the Fourier Series of x(t).
16. Why is MATLAB telling me that the inner matrix dimensions don’t agree when I write the statement Hw=b/(a+j*ww)?
ANSWER: If ww is a vector, then you need to do POINT-WISE division with the ./ operator. Also, the vectors a, b and ww must be of the same length to do the ./ operator.
(11)4.2 Finding the Output Signal
1. What is the difference between yN(t)in section 4.2(a) and y10(t)in section 4.2(b)? Is the process for getting both outputs the same as described in Section 4.2(b)? The only difference I see in Section 4.2(a) is that N=5 instead of N=10. But each section has a different heading: Frequency Domain and Time Domain.
ANSWER: Follow the steps in each section independently. Use N=5 in one case and N=10 in the other. Different types plots are needed for the TIME and FREQUENCY domains.
2. It says to make spectrum plots of xn(t) and yn(t). Does this mean that we have to figure out the ak coeffiecients by hand? If so, is there anywhere I can see an example? Do we do the spectrum plots by hand? How do we take the absolute value of vt = 120*sqrt(2)*cos(120*pi*t) by hand?
ANSWER: You don’t actually have to use the absolute value inside the Fourier Series analysis integral to get the Fourier Series coefficients. Make a sketch of xn(t). Determine its FUNDAMENTAL period. Then write a formula for xn(t) over that period alone. The absolute value will only come into play when making the sketch. Also you should have a plot of xn(t) from Lab #10. FUNDAMENTAL period is the shortest period. Note that xn(t) should be plotted versus “t” (time). Then “k” is an index that is related to frequency.
3. In the plot of the spectrum of xn(t), the horizontal axis should be “omega” (frequency). You have to convert “k” to “omega”. You need to answer the following: the k-th FS term is at a frequency of omega (= what?) in rad/sec. Once you get the spectrum plotted versus omega, then H(jw) will line up. One last suggestion: look at some of the plots of the spectrum in Chapter 3. For example, Fig. 3.12. The horizontal axis is in Hz, but could be converted to rad/sec.
ANSWER: You should have used the symbolic toolbox to get a formula for the coefficients. At least for xn(t). Use the frequency response property to convert the Fourier coeffs of xn(t) into the Fourier coeffs of yn(t). One good example of the procedure is the problem from HW #12. Different Fourier series, but same idea of FILTERING. You should program MATLAB to plot the spectrum. Use stem(). To eliminate the circles at the top of the stems, make the 3rd argument into stem() be ‘.’ (that’s a period in single quotes).
4. In calculating yN(t),should we redefine our H(jw) to contain w0 and then send ak*Hjk into the fouriersynth() function? How do we evaluate H(jw) for every fundamental frequency of k?
ANSWER: You should not have to re-define H(jw). The function fouriersynth() creates a time signal, so you will use it in 4.2(b). Use the subs() function. The function subs() lets you substitute numbers, or a vector of numbers, into a symbolic formula. It returns a vector of numbers. Also, remember that you can multiply two symbolic formulae in MATLAB, Then send the product into fouriersynth() and let fouriersynth() do the subs() evaluation as it creates the time signal.
5. To obtain y(t) for N = 10, I first got an equation for H(jw) in terms of k, with k
being the symbolic variable, and then I multiplied this symbolic expression with ak to get bk. However, my output y(t) does not look anything like the output obtained in Lab #10, but is just a typical sinusoidal curve.
ANSWER: Can you isolate the Fourier coefficients and their values? If so, you can get their magnitudes. You should get a non-zero D.C. term (k=0) and then other Fourier coefficients that are smaller. You will NOT see the transient, so it won’t be identical to the last lab. Think of the reason why you will not see the start-up transient. Why do you only see the “steady-state” portion of the output signal?
6. I have a question related to the following excerpt from another posted question:
“To obtain yt for N = 10, I first got an equation for H(jw) in terms of k, with k being the symbolic variable in it…”
How did this student obtain the expression for H(jw) in terms of k? I have mine in terms of w, without any k. This comes directly from the Fourier transform of h(t) in section 4.1 of the write-up. Also, when do I use ezplot() and plot()? For instance in 4.2(a), I’m not sure whether to use plot() or ezplot() because some of my expressions are symbolic, which suggests ezplot(), but I can also define a range of values for omega and use plot().
ANSWER: There should be no “k” in the expression for H(w). However, if you evaluate H(w) at the frequencies of interest, then you might get a “k” because those frequencies depend on “k”.
7. I have an expression for x3(t), ak, and H(j*w). The H(j*w) is a symbolic equation in terms of w. How do I substitute w0 = 2*pi/To for w in H? Do I multiply ak and H(j*wo) to get bk?
ANSWER: Yes, use the subs() function to replace a symbolic variable. Look back to section 3.3 of the warm-up for an example.
8. What are the ranges that we should use to do the three plots? ([1] x3t, [2] magnitude H(jw), and [3] y5t.)
ANSWER: For time plots show several periods, so you can compare to the “correct” answer. For H(jw) show a range that covers the first 3 or 4 harmonics of the input signal. You want to be able to justify that only the first harmonic is needed at the output of the filter.
9. How should the spectrum plots look for section 4.2(a)? I have used stemplot() and my plot looks like the absolute value of a sinusoid.
ANSWER: I assume you are using stem to plot the ak or bk coeffs. They should not look sinusoidal. The Fourier coefficients usually get smaller (in magnitude) as k increases. Hopefully, it is your “time” plot that looks like the absolute value of a sinusoid.
10. How we are supposed to find H(w) from H(jw), what are the “correct frequencies” that we are supposed to substitute in, and where does the k come from?
ANSWER: Remember that the Fourier Series is a representation as a sum of complex exponentials. What are the frequencies of those complex exponentials? These are the input frequencies. The “k” is the index that tells us which component is under consideration. So, ak is multiplying a complex exponential at what frequency?
11. When I plot xn(t), should I use absolute value for the stem plot and does it resemble a sinusoid that dies out for positive and negative infinity? Next, H(jw) should look like a low pass filter, and finally, yn(t) should look like the filtered xn(t), in which case only frequencies semi-close to 0 will be passed?
ANSWER: Not stem(); use plot() because x(t) is a function of the continuous variable “t”. xn(t) should be a very close approximation of the rectified sinusoid. It should NOT die out. YES, and yn(t) should look like the steady-state part of Lab #10. (D.C. plus a ripple). The ak values do die out. Its not really a sinusoid, but it might look like a “sinc” function. The “sinc” will oscillate but its height decreases as k gets larger. And a stem() plot (with abs) is the correct format for the spectrum*.
12. My time range in lab 10 does not match that of the same signal from lab 11; i.e., if I plot from zero to 11*T0 from lab 10, I get only a small spot on my plot, not the sinusoid. My range for the plot in lab 10 goes from 0 to 325?
ANSWER: With a range of 0 to 325, that can’t be seconds. Maybe it was sample number. What was the vector for the horizontal axis? You should see 11 periods in Lab #10.
Can you re-run the Lab 10 file? You just need a plot of the steady-state portion.
I picked 11*T0 because I thought that was long enough to overlap with the steady-state region from Lab #10.
13. It says “plot the spectrum of…” How do I plot the spectrum of something in MATLAB? or does this mean by hand?
ANSWER: In MATLAB use stem() which can plot vertical lines. Example:
stem( ff, aa, ‘.’ )
14. What are we suppose to plot the stems of, ak or xN(t)? If its xN(t) then how can you do a stem plot when there is a t in the formula? When I plot the stem of ak, I get a “divide by zero” error when k = 1. I want to know what I am suppose to be plotting here…ak, bk, or xN(t)?
ANSWER: 4.2(a) is the frequency domain, so plot ak and bk. Evaluate at k = (1 + 1e-9) which is real close to k=1. To get xN(t) from Fourier synthesis, go back and use the ideas that were in sinus() and vsinus() from an earlier lab. I think you’re doing this numerically. If not, use fouriersynth.m for the symbolic approach.
15. I’m trying to do a stem plot of xN(t). My horizontal axis goes from -3 to 3, with values plotted at each integer. All the magnitudes are equal.
ANSWER: Do you want a stem plot for the *spectrum* of xN(t) ? I think so. The spectrum comes from the FS coefficients, the ak. If you are plotting xN(t) vs. t (time), then use plot().
16. I have plotted xN(t) and H(jw), but I am stuck on how to attain discrete values for yN(t). I also don’t know if my “frequency ranges” line up.
ANSWER: You should be plotting the *spectrum* of xN(t) and the Spectrum of yN(t). The spectrum is determined by the ak and bk coefficients. You want to end up with a line spectrum like we had in Chapter 3. Also, convert “k” to omega.
17. I can’t get the spectrum to print out correctly. I have ak, bk and h(jwk)and when I graph them I get a ONE vertical line for each bk and ak and then a bunch of dots on a horizontal line for h(jwk). What should my w in stem(w, ak) be? I thought w was symbolic, w = 2*pi/T0? What should my graphs look like, roughly?
ANSWER: stem() needs NUMERIC inputs. Use subs() to evaluate a numeric expression at a set of values and get numbers back. For example: subs( ak, k, -5:5 ). Each ak is the complex amplitude at a certain frequency, related to w0. The spectrum plots for ak and bk should look something like Fig 3.12 in the book. H(jw) vs. w should be a continuous plot.
18. When we plot H(jw), should we represent w symbolically? Or do we use a range for w like we did in 4.1(a)? If I do it like 4.1(a), its no problem. But if I do it symbolically, then I get a strange looking graph. But to substitute the value w0 in for w implies that w should be symbolic.
ANSWER: I would suggest that you do NOT do it symbolically. You want a continuous plot versus w over a range of frequencies that includes the first 3 harmonics of x(t); you should NOT have to substitute w0 for w.
19. How do we plot the specgram for xnt when we already have the ak coeffiecients?
ANSWER: You shouldn’t be plotting the specgram because that’s a frequency vs. time plot. You want a plot of the spectrum, ak versus frequency. Use stem() to plot vertical lines. Determine the frequency for each ak; call that vector fk. Then do stem( fk, abs(ak), ‘.’ )The ‘.’ will prevent stem from putting circles at the top of the vertical lines.
20. I fail to see where the given “true impulse response” came from. Can that be pointed out, please?
ANSWER: The impulse response was obtained using the Laplace transform. We’re just giving it to you without saying how to derive it. Since you are not learning about the Laplace transform in this class, just take it as a given. More information to satisfy your curiosity: The Laplace transform was used to find the impulse response in a similar manner to the way you have been using the z-transform to find the impulse response, i.e.,
1) Take the transform of both sides of the equation.
2) Do some algebraic manipulations to find H(w) = Y(w)/X(w)
3) Use partial fractions to split the result into terms containing only a single pole.
4) Use the known inverse transform of the single pole terms to transform the equation back into the time domain.
The procedure is the same whether you are using the Laplace transform with continuous-time differential equations or you are using the Z Transform with discrete-time difference equations. The differences just lie in the specifics of the transform pairs.
PART II: Design with Fourier Series
1. How Ts is chosen so that the simulation is closest to the theoretically answer?
ANSWER: As Ts—> 0 it has to work. So a very small value will do the trick. The size of Ts depends on what you are trying to simulate. The warm-up gives a few suggested values.
(10)4.1 Simulation of a Power Supply Circuit
1. Please clarify this for me as I am confused: the first paragraph refers to figure 1 as a full wave rectifier. The last paragraph at the bottom of the page calls it an R-C circuit. Figure two has two things in it, a full wave rectifier and an R-C circuit.
ANSWER: There are TWO parts:
(1) full-wave rectifier implemented with a diode bridge
(2) Lowpass filter implemented with an RC-circuit.
(10)4.2 Actual Simulation
1. When I test the system, the output sinusoid varies from .036 to .043. Is this close enough to say the signal is D.C.? What are the limits for a fair answer?
ANSWER: Read on to part 4.3. There will always be ripple. You have to measure it.
2. I’m not sure whether I am going in the right direction: my function takes in Ts, R, & C, then calculates aa & bb (according to the difference equation). I set my time interval (tt) from 0:Ts:20*Ts, (I tried using tt from 0:Ts:20 but, the function runs for too long and my computer crashed) and my input signal is v = 120*1.414*cos(120*tt). My rectified signal is the magnitude of the input signal, and my output signal is calculated using filter (passing in aa, bb & v). My plots look abnormal. What might I be doing incorrectly?
ANSWER: What is Ts? You can figure out the length of the vector 0:Ts:20. Every vector in the simulation will be that long. If it’s too long for your computer’s memory, then your options are:
1. change computers
2. change Ts
3. change 20
If you make Ts too big, then the simulation is not faithful. Ts =1 sec is too big. Use a stem plot for the output of the IIR simulation. Check your filter coefficients. The RC filter is low pass. Therefore, you should have some intuition about the location of the pole of the IIR simulation. Do a pole-zero plot to check.
Another important comment: This is why part 4.2(d) asks you to find the **largest** possible Ts. Choosing Ts to be very small is great for making the simulation “faithful” but it requires a very large amount of memory. Also, I believe tt should be something like tt=0:Ts:?/60 because you want a certain number of periods for the input function.
3. Is the graph in this section as smooth as the one we create in warm-up section? I think it might not be, since it has only one feedback and in the warm-up we have two feedbacks. Also, how do we know about the frequency in the output? I tested the input and the output and found that the input signal is only 60 Hz; however, after taking the absolute value it has frequency in every range.
ANSWER: Actually, it should be very smooth. It is a low pass filter. Check your pole location for the IIR simulation. The RC circuit is a LOWPASS filter. So what does that do to the frequency content of the input?
4. I do not fully understand the derivation to find the backward difference approximation in 4.2(a). I follow the derivation in the introduction until equation 9. I do not understand how equations 6, 8, and 5 were combined to produce equation 9.
ANSWER: Equation (6) is substituted into equation (5) for y^(1). Equation (8) is substituted into equation(5) for y^(2). Then all the y(nTs) terms are grouped. All the y(nTs-Ts) terms are grouped, etc. Divide out the term multiplying y(nTs).
5. What is the difference between 4.2 (c) & (d)? Part (c) asks us to find a value of Ts that gives a faithful approximation and part (d) asks us to find the largest value of Ts that gives a faithful approximation. This question seems repetitious, since we could set Ts=10^-5 in section (c) because section (d) uses that starting value for a minimum faithful simulation.
Also, should we watch v(nTs), x(nTs), or y(nTs) when deciding what is a faithful simulation value for Ts? I’ve been watching v and x because y doesn’t seem to change all that much even when I go way over the Nyquist sampling frequency/period. But, in section 4.2(d), it says “keep making Ts larger until the OUTPUT starts to change noticeably.” Is output the graph or the output of the system (y(nTs)).
ANSWER: You’re right: part (c) is “do it”, part (d) is “do it with the largest possible value of Ts.” I was trying to emphasize that one could do a little work to get a value for Ts that would be “optimal” or good in some sense. And, you should be watching y() primarily, because it is the only signal that depends on the “simulation of the filter.” Note that y() is the output of the RC filter and also the output of the system.
6. What should my graph for the output y(t) look like ? A horizontal line like a constant? Or a sinusoid?
ANSWER: It will be a constant plus a sinusoid. The constant term is the DC voltage. The sinusoid is the ripple. This is after you ignore the start-up transient.
7. I don’t get a D.C. component in my plot. I only see a sinusoid. I took as aa and bb the coefficients that I derived from the differential equation operations done in part (a). For the period, I used tt = 0:Ts:1/3. My voltage signal is v = 120*1.14*cos(120*pi*tt). Then my rectified output is x = abs(v). I used x as my input for getting the final output through the y =filter(bb,aa,x) operation, then I plotted y and got a smooth sinusoid, but no constant anywhere.
ANSWER: Check the filter coefficients. You have an IIR filter. Check the value of the pole. The filter should be a low-pass, so you should expect the pole to be in a certain region of the z-plane.
8. I know that the plot of the final output should look like a constant plus a sinusoid, but for some reason I only get the sinusoid part.
ANSWER: Your simulation is an IIR filter. The filter has a pole. Determine the location of that pole from your filter coefficients. The IIR filter is supposed to be simulating a lowpass filter (i.e., the RC circuit is lowpass). If you don’t have the correct coefficients, and had a highpass by mistake, then you get zero DC output. Can you explain this last statement to yourself? Why is it true for all highpass filters?
9. My y(t) is exhibits exponential growth. My bb = 0, and aa = [1,-1.098]. Using PEZ, it looks like a low pass.
ANSWER: Must have an UNSTABLE filter. Is the pole outside the UC? If so, then it can’t be the correct filter. Check your derivation of the filter coefficients.
10. How do you plot v(nTs), and is this different from plotting v(t)?
ANSWER: Use plot() to plot it as a continuous signal, use stem() to show the samples as a discrete-time signal, i.e., v[n] = v(nTs).
11. I am confused about the output y(t). I found bb and aa and used y = freekz(bb,aa,x) where x is the absolute value of v(t). I then plotted this using tt = 0:0.001:(2/3) and plot(tt,y). What I get is a signal that has a period nothing like what is expected; mine just fluctuates from just above 0 to .6 in a strange manner. I plotted the pole in the z-plane and found a pole to be located on the real axis close to one. Changing Ts caused it to move closer to the center of the unit circle.
ANSWER: You should be using filter() instead of freqz(); what you are simulating is a low pass filter that passes the d.c. frequency with some leftover sinusoid.
12. When I plot v(nTs) and x(nTs) do I use stem() or plot()? Also, in 4.2(b), it says to plot the input v(nTs) over the time interval of the last ten periods of v(t). What does this mean? Finally, how many plots should I end up with in 4.2(b)?
ANSWER: Since you are trying to mimic a continuous-time system I would suggest using plot(). This gives the appearance of a continuous waveform (even though it is actually connecting discrete points.) If you were interested in the discrete nature of the simulation, then stem() would be better. Go far enough out in time to get past the transient part of the response. You want a plot of the steady-state region. If you run the simulation for a long time, you can work backward from the ending time to get the last ten periods because the output (in the steady-state region) looks periodic. The total number of plots required is 3.
13. I am unsure what the vector “tt” should be.
ANSWER: The vector tt is the time base of the simulation in SECONDS. tt = starting_time: time_increment : ending_time.
14. I am having difficulty with the filter. If I am correct you must substitute (3) into (11) and then solve for y(NTs) so that you can derive your filter coefficients. Then aa should be of order 2, correct? And bb is of order 1?
ANSWER: Your methods and assumptions are correct. Check the algebra. Also, the IIR filter has a pole. Check the pole location. Make sure that it is appropriate for a STABLE filter and also appropriate for a LOW-PASS. You should know where the pole is located (approximately) under those two conditions.
15. My question is about the magnitude of the frequency response of our RC filter. When I use freqz() to plot the magnitude, it shows a lowpass filter, but the maximum magnitude (at zero, of course) is around 0.07 or so. Typically, these things are built to give maximum magnitude of 1. I noticed this because my D.C. component is much smaller than I expected. I suspect I’m doing something wrong.
ANSWER: Nothing is wrong. In this case the D.C. gain is LESS THAN 1, much less in fact. With a physical system like a passive RC circuit, the gain can never be greater than 1. Often it is much less. You would need an active circuit (with an AMPLIFIER) to get gains bigger than one. So here’s a question: can you make the D.C. output voltage bigger than 100 volts D.C.? What is the largest D.C. output voltage obtainable with this kind of system? You can’t just scale an analog filter to change its gain. The gain is dictated by the laws of physics (in this case, the laws of electric circuits)
16. I obtained the correct output, but am having trouble isolating the Ts to use. If I adhere strictly to the sampling theorem, and consider the actions of rectifier, the Ts I obtain doesn’t seem to work when I plot it. I don’t know where to stop my increase of Ts. After a while, the output is still similar to D.C., but less smooth (like a sinusoid) and with more peaks.
ANSWER: Once the output changes, your Ts is too big. Remember that you are trying to simulate a fixed analog system. There is only one correct answer. In the simulation you are trying to approximate that answer. If Ts gets too big, your approximation is no longer any good. DON’T try to control/change ripple and DC with Ts!
17. How do we go about determining whether or not the rectifier output has frequency components at frequencies higher than 60Hz? Also, when determining the maximum value of Ts that can be used, what qualifies as a “noticeable change”? Is it when the output signal starts looking jagged?
ANSWER: What is the period of the rectified output? What is its fundamental frequency?
18. I am not sure how to skip the transient response and graph only the last 10 periods.
ANSWER: You can graph the first 20 periods, just ignore the first 10 when you analyze it (read, when you eyeball it).
(10)4.3 Output Voltage and Ripple
1. In this section it says to use “the value of Ts determined in the previous part.” Which value is this? Does it have to be the largest value of Ts that we found, or can it be one smaller?
ANSWER: The point of 4.3 is to experiment with R and C, so the value of Ts is secondary.
Try to stay near the “largest” value, but Ts could be somewhat smaller. If you make Ts very small, then your simulation will be inefficient and run a long time. In fact, Ts depends on C and R, so you should make it smaller (than the max from 4.2(d)). One other caveat: If you ever doubt the “faithfulness” of the simulation, then make Ts very small. In the limit as Ts–>0 the simulation has to be “faithful.”
2. Since I want to know what is the “D.C. value of the output voltage” and “the peak to peak ripple of the volts,” could you point out which part of the plot you are asking for? Also, the output is a sinusoid, it’s not a straight line + sinusoid. Where is D.C.? I know the ripple is the sinusoid, but which part of the sinusoid?
ANSWER: D.C., as we’ve defined it, means the constant term, or average value. Then subtract out D.C. What’s left is the ripple–it will look like a sinusoid. A sinusoid is defined by y(t) = C + A*cos(B*t – D) where C is the constant term added to the (A*cos(Bx – D)) term which is the sinusoid. When you compute the mean(), make sure that you ignore the start-up transient part of the output signal.
3. What is meant by “less than 0.5 volts of peak to peak ripple about the constant output value (i.e.+- 0.25)?” Can you explain “peak to peak”?
ANSWER: You should have a sinusoidal component riding on top of a D.C. value (constant). “Peak-to-peak” means the measurement of amplitude from the top of a positive peak to the bottom of a negative trough.
EX: 2*sin(wt)varies from +2 to -2, so its peak-to-peak value is 4.
4. I know the ripple is a sinusoid, but, which part are we suppose to measure? I haven’t learned voltage, so what is voltage out my output plot?
ANSWER: Note that y(t) is the output signal. It has units of volts, so we also call it “voltage” or a “voltage waveform” or a “voltage signal.” Measure the output signal.
5. Looking at my output y(t) from the previous sections, it definitely looks like a sinusoid, but it is centered on the x-axis. This implies that the DC component is zero, which I believe may be wrong. The ‘peak-to-peak’ ripple is approximately 5. The filter that I used to create this takes in a,b and x(t), with x(t) based on v(t).
ANSWER: Did you remember that you must incorporate the absolute value of the input voltage v(t)? Not doing so could cause your y(t) to hang out at 0 instead of the dc voltage.
6. Could you provide a clear explanation of what “peak-to-peak” means? Does this refer to the amplitude or the period?
ANSWER: Amplitude: Top to Bottom.
7. I can’t seem to get the peak to peak value down to 0.5. The best I’ve found so far is 0.6851. Since I can’t change anything but C, how can I narrow it further?
ANSWER: C is the only thing that controls the ripple, as you will discover (in detail) during Lab #11. Maybe there is a bug somewhere else. Make sure to take note of the magnitude of the y-axis scale in those plots. The function ezplot() has a bad (IMHO) habit of always using 2 or 3 digits of precision for labeling the axis, but then it will sneak a x10^-4 or some such multiplier onto the graph somewhere.
8. How do I choose R anc C for the given conditions? I’ve tried several different combinations but it never seems to work. I don’t see any consistent pattern when I vary them. Is there any mathematical relationship among these parameters and Vpp, or anything to look for?
ANSWER: Vary them one at a time. You be able to see which one controls the ripple and which one controls the D.C. level of the output.
(10)4.1 Fourier Analysis of Full Wave Rectifier Output
1. At the end of part 4.1 (a), it tells us to make a plot of H(jw). How do we make a plot of a function with two undefined constants “alpha” and “beta” using MATLAB? Do we need to use the Symbolic Toolbox for this?
ANSWER: At the end of section 4.1(a), the write-up says to use some typical values (or R and C) to test out your frequency response plotting code. You’ll use it later in the lab. You’re right that you need numerical values to do this.
2. When we are instructed to “make symbolic MATLAB expressions for the functions v(t) and x(t),” what is the x(t)? If it is the series expression, how do I express that symbolically with MATLAB? Also, what do I do with the Fourier coefficients? Do I have to compute them? In determining the fundamental period To, where is the full-wave rectified output signal, and how do I handle x(t) = x(t + To)?
ANSWER: It is not the series expression yet. X(t) is the FULL-WAVE rectified cosine signal. You need to figure out the period of x(t) first. Can you draw a sketch of the full-wave rectified sinusoid? If so, you can see what the period is from the sketch.
Once you have the period, then use the sketch to figure out a formula for the signal over one period. (i.e., come up with a cosine function that will simulate the rectified output of v(t).) Finally, put that formula into an integral and get the a_k’s. MATLAB/MAPLE can do this for you. It is very similar to the warm-up, section 3.5. Do you remember the formula for the function that was treated in that section, and the plot of that function? That was a HALF-wave rectified sine. Now we are doing a FULL-wave rectified cosine.
3. Where or how do I find beta? Alpha is given to be (220 + R)/(220RC).
ANSWER: Frequency Response H(jw) is Fourier Transform of the impulse response, h(t). H(t) was given. Take its FT (easy because it is one-sided exponential) and then identify “beta.”
4. After reading the notes, I thought h(jw) = (RC) / jw + a, but don’t you have to use the symbolic toolbox for all this?
ANSWER: You could use the symbolic toolbox: use ezplot() and subs(), OR you can do it numerically: write a little function that takes R and C as inputs and then
1. computes alpha and beta
2. sets up a dense frequency grid for “w”
3. evaluates H on that grid.
4. returns H
5. I am not sure what we are supposed to do here; is this similar to part 3.5 of the warm up? If so, what is wwk?
ANSWER: NO, 4.1 is just write a function to plot the frequency response. And, wwk = exp(-j*k*w0*t) , it just has w0 written as 2*pi/T0.
6. I have a question related to the following excerpt from another posted question:
“To obtain yt for N = 10, I first got an equation for H(jw) in terms of k, R and C, with k being the symbolic variable in it…”
How did this student obtain the expression for H(jw) in terms of k? I have mine in terms of R, C, and w, without any k. This comes directly from the Fourier transform of h(t) in section 4.1 of the write-up. Also, when do I use ezplot() and plot()? For instance in 4.2(a), I’m not sure whether to use plot() or ezplot() because some of my expressions are symbolic, which suggests ezplot(), but I can also define a range of values for omega and use plot().
ANSWER: There should be no “k” in the expression for H(w). However, if you evaluate H(w) at the frequencies of interest, then you might get a “k” because those frequencies depend on “k”.
(11)4.3 Designing the Power Supply in the Frequency Domain
1. I can’t get part 4.3(c) to work properly. According to my equation for ak, if I use the value of 1 or –1, I will be dividing by zero. I believe my equation is correct, so to get around this problem can I just use the value of 2 and -2 for my ripple?
ANSWER: Sounds like your fundamental frequency/period is wrong. But, you can use the lowest harmonic and you should get the same answer. Consider the following: x(t) has a period of 5 seconds, but I choose w0 to be 2*pi/10 for my Fourier Series (thinking the period is 10). I can still get ak coefficients. Can you PROVE that a1 has to be zero in this case?
2. Does the period of the ripple come from exp^(j*k*w0*t) or does it come from some part of the derivation of the complex numbers? I come up with a fairly messy expression for the two complex numbers that make up the sinusoid in y(t). Do I have to find some way of expressing these two complex numbers as one sinusoid? How should the magnitude of the first sinusoidal term be expressed?
ANSWER: Yes you have to combine them in order to get the magnitude of the “ripple term.” You need to express this in terms of R and C. Also you need the magnitude of the DC term (for the output).
3. To get the magnitude of the ripple term, should I use the property abs(z)^2 = z*conj(z) on both terms? I’m a little unsure of how to find a formula that expresses the magnitude of the two complex numbers that make up the sinusoid.
ANSWER: I think you are putting together the terms that have bk and b(-k) ? If so, use Euler’s formula because one term is the conjugate of the other. Then you combine to get the real cosine function. From that you can see the magnitude. This should go back to how we combined spectrum terms in Chapter 3.
4. What do we do if the bk’s are imaginary? do we take the absolute value of that?
ANSWER: Remember you can combine the following into a sine, or cosine with a phase of pi/2:
j*exp(j*100*t) – j*exp(-j*100*t) –> A*cos(100t + phi)
The positive and negative frequency terms will be complex conjugates of one another !!!
5. I can’t seem to understand the general concept for this portion of the lab.
ANSWER: Go back and read chapter 3 in the book. You have a spectrum and you want to write the formula for a time signal that contains only cosine terms and a constant. This should be easy. Now, if y(t) is the output, The Fourier Series derivations tell you that it is possible to approximate y(t) as
y(t) = K1 + K2*cos(w0*t + phi) + other very small terms
Both K1 and K2 depend on R and C. Given specs on K1 and K2 you can write 2 equations in 2 unknowns to solve for R and C. This is hard.
6. I came up with bk values that are complex. How do I come up with a decent sinusoid? For b1 I have:
1393790827673997775/17592186044416/(528000*i*pi*R*C+2200+R)
and I have the same thing for b(-1).
ANSWER: evaluate 1393790827673997775/17592186044416 to get a number. Read Chapter 3 to recall how to combine the FS terms for b1 and b(-1). You can get a cosine. The amplitude of the cosine can be written in terms of b1, and hence in terms of R and C. It is messy because you will get a square root, but it’s not intractable.
7. I’m confused on how to do 4.3b. I believe you begin with:
(1/To) * int(xt,t,0,To) [xt being abs(vt)]
But how do you get in terms of R and C, or really just R?
ANSWER: Note that x(t) is the input. It does not depend on R and C. R and C come into play when you create the output. H(jw) depends on R and C. Write alpha and beta in terms of R and C. You don’t need an integral for the output FS. You should be able to track the input FS coeffs through the filter. You want to combine ak with H(jw), as you did in 4.2(a). You have a formula for H(jw) in terms of R and C, after you convert alpha and beta to their forms in terms of R and C. D.C. means a certain frequency on a plot of H(jw) vs w.
You need the D.C. value of H(jw), so you need to evaluate H(jw) at omega = D.C., and D.C. is which frequency? To define D.C.: It means omega=0, because that is the frequency where e^(jwt) is a constant. In Electrical Circuits, D.C. means “Direct Current” which is a constant value. Probably sounds like strange terminology, but EEs use the term D.C. to mean zero freq. As in the “D.C. level” of the signal. Be sure you have the right expressions for beta and alpha. your final answer is checkable, just look at what your dc value of the output signal is; you got this by multiplying your H(j0) by your a0, so you can check it!
Get your formula in terms of R and C for H (jw) which you should arrive at by substituting for beta and alpha. Then just enter it symbolically in MATLAB and evaluate the expression by doing a substitution for the frequency of interest, which is the D.C. frequency, which is NOT 6.25. Think about where you normally look on a FREQUENCY spectrum to find the D.C. component.
8. When you say in part 4.3(c) the “period” of the ripple, how does that differ from (a) the period of the shifted sinusoid, or (b) the peak to peak of the shifted sinusoid?
ANSWER: It is (a) period of the shifted sinusoid. By shifted, I assume you mean shifted up by the D.C. level. Period is a time, so it can’t be peak-to-peak which is volts. Let’s hope it’s the same as for x(t). Remember: Sinusoid in gives sinusoid out at the same frequency. Only magnitude and phase change. We are claiming that the ripple is due mostly to the first harmonic and that’s all were keeping track of. There is some error, because the output actually has higher harmonics. But how big/small are they?
9. I understand that bo = Vout, but does b1 = Vripple? Or is Vripple = y1(t). If this is the case, what happens with the cos(wo*t + phi) term, specifically the t when solving for C?
ANSWER: Vripple is the “size” of y1(t). peak-to-peak, or amplitude. You can get the “size” from b1.
10. I worked this part out (I think) mathematically using R and C in my expressions for b1 and b(-1), and determined that (the cosine part being fairly straightforward) I could combine my expressions for b1 and b(-1) multiplied by a1 to get the magnitude, thus getting the expression in terms of R and C. Is this what you are looking for?
ANSWER: Sounds right. R and C should enter via the magnitude of the frequency response.
11. My understanding of 4.3(b) is as follows: ak = the same ak that we used in 4.2? H(jw) = H(j*0) where we are no longer dependant upon C, and bk*e^jkwt = bk*constant.
ANSWER: Sounds correct.