Creating a Triangle Wave Exercise

advertisement
Chapter 2
MATLAB EXERCISE
Creating a Triangle Wave Exercise
Using fplot, the sum function, and vector operations, create a triangle wave that looks similar to the
one below.
2
1.5
1
0.5
0
-0.5
-1
-1.5
-2
0
0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009
0.01
You can model your solution after the fplot formula for the square wave given in the book:
>> fplot('sum(sin(2*pi*262*([1:2:101])*t)./([1:2:101]))',[0 0.005 -1
1])
This formula evaluates the sine function over 51 terms, getting alternative positive and negative
frequency components. Try to do something analogous for the triangle wave, which is created as
the sum of odd-numbered harmonics that alternate in sign, as defined below.
Let f be a fundamental frequency. Then a triangle wave created from this
fundamental frequency is defined by the infinite summation
Digital Sound & Music
Creating a Triangle Wave Exercise
MATLAB EXERCISE
Page 1
This material is based on work supported by the National Science Foundation under CCLI Grant DUE 0717743, Jennifer Burg PI, Jason Romney, Co-PI.
Download