LAB 10 F. A. Q.
1. When I try to run fplot or quad8, I get a lot of
“matrix dimensions do not agree” errors. I don’t see any matrices or vectors in my function that
What’s going on?
and fplot will turn the time variable into a vector. If you are not careful, this can cause problems. Remember to think of the time variable
as a vector when you write your function, and use the dot operator
appropriately. In particular, multiplications by “t” should be
array multiplications, “.*”
2. I keep getting warnings about recursion limits reached, but
everything seems to be working fine.
The messages are really annoying and I’d like to get rid of
them. What is causing them?
quad8 tries to integrate a function that contains sharp corners, it generates
the warnings you are getting.
These warnings are generally not a real problem. If you want to get rid of all the warnings,
type warning off in the command window.
Go to helpwin warning for more info on warnings.
3. The section in the warmup where we passed empty sets of
brackets to quad8 and fplot confused me.
What was that for? Will I
have to do that in this lab?
quad8 and fplot functions have lots of parameters we can pass to them, but don’t
bother to. If you do not pass
these parameters, the function has default values that it chooses. If we want to pass the
function a parameter that is after one of these parameters in the parameter
list, then we have to pass an empty bracket set as a placeholder. The function will use the default
values when it sees these empty brackets.
Type helpwin fplot or helpwin quad8 for more information on these
You may or may not need to do this in your lab, depending
on the approach you take. If you
pass multiple parameters to a function that you integrate, then you will need
to do this.
4. I’m confused on how to use the mod function. How can I use it to keep the time
values in one period?
you take A mod B, then the mod function will add or subtract B from A
repeatedly until the result is between zero and B-1. A good example of this is a clock. When you give the time, you say the time mod 12. You wouldn’t say to someone,
“it’s 16 o’clock”, rather you would subtract 12 and
give say that it was four.
Likewise, you would say it was 11 o’clock rather than –1
o’clock. Type helpwin mod to
get more details on how to use mod.
In this lab, you will need to make a function that is
multiplied by a boolean (zero or one) like in the example in 4.2b. The key here is to figure out what
range you want to multiply by one and what range you want to multiply by zero.
5. The lab refers to four periods in the range -0.075 to 0.075,
but I don’t get quite that many.
What’s going on?
period of the cosine inside the definition of the “rectified”
sinusoid is 0.04, but the lab defines the period of the periodic signal as
0.05. This was deliberate. You cannot use the period of the cosine part as the
period of the signal.
When you plot from -0.075 to 0.075, you should get exactly
6. How do I figure out what fundamental frequency (f0) to use
in my Fourier Series analysis?
fundamental frequency will be the inverse of the fundamental period. The fundamental period is just the
period at which the function starts to repeat again. The fundamental frequency and period have nothing to do with
what the function looks like inside of a given period, only how long it takes
7. Should I use equation (7) in my Fourier analysis?
do NOT use equation 7. It exists
only to remind you of the similar problem you tackled in an old lab. Use equation (2) for your Fourier
analysis, with equation (5) defining the function.
8. When do I call my vsynthesis function, and what do I assign
to fk and Xk?
vsynthesis function is called to perform the Fourier synthesis in equation (6);
note the similarity here to equation (1).
The fk that you pass in will be a vector of k’s times the
fundamental frequency, while the Xk will be the ak’s that you produced in
your Fourier analysis integral.
9. What calculations am I expected to do in section 4.4?
in hand calculations that derive the ak from the integral equation (2). Compare the ak results to the results
in the table you produced in section 4.3c.
10. Examples of using quad8, functions, and
Integrating this by hand,
the result is
So, the answer is
The results for aa and
aa2 are the same. Note how the
functions are declared and how they are associated with each other. See help quad8, help inline.
The integrating limits
are 0 and 5. Notice the variable
of integration is not re-defined in the quad8 function, but it is understood
that the values after the function declaration are intended for the variable
‘t.’ When using the inline declaration, all the variables are
defined, and the first variable is the variable of integration.