![]() Notice that the offset is given in units of radians rather than degrees, 180 o being equal to radians. Figure 2.31 Two sine waves, one offset 180° from the other In Figure 2.31, the 0-phase-offset sine wave is in red and the 180 o phase offset sine wave is in blue. We have two phase-offset graphs on the same plot. This will cause all future graphs to be drawn on the currently open figure. To do so, we graph the first function with the command fplot('2*sin(262*2*pi*t)', ) We can show this by graphing both sine waves on the same graph. When we add θ to the sine wave, we are creating a sine wave with a phase offset of θ compared to a sine wave with phase offset of 0. Phase is essentially a relationship between two sine waves with the same frequency. To change the phase of the sine wave, we add a value θ. If A > 1, we may have to alter the range of the vertical axis to accommodate the higher amplitude, as in fplot('2*sin(262*2*pi*t)', ) Īfter multiplying by A=2 in the statement above, the top of the sine wave goes to 2 rather than 1. If we want to change the amplitude of our sine wave, we can insert a value for A. The horizontal axis goes from 0 to 0.05, and the vertical axis goes from –1.5 to 1.5. The portion in square brackets indicates the limits of the horizontal and vertical axes. Also, notice that the constant π is represented as pi in MATLAB. Notice that the function you want to graph is enclosed in single quotes. The graph in Figure 2.30 pops open when you type in the above command and hit Enter. To create a sine wave in MATLAB at this frequency and plot the graph, we can use the fplot function as follows: fplot('sin(262*2*pi*t)', ) Middle C on a piano keyboard has a frequency of approximately 262 Hz. Now let’s look at how we can model sounds with sine functions in MATLAB. MATLAB’s sine function expects angular frequency in Hertz, so f must be multiplied by 2π. In our examples below, we show the frequency in Hertz, but you should be aware of these two equivalent forms of the sine function. $$!y=A\sin \left ( \omega t+\theta \right )$$ We can now give an alternative form for the sine function.Ī single-frequency sound wave with angular frequency ω, amplitude, and A phase θ is represented by the sine function Then the angular frequency, ω, in radians/s, is given by Let f be the frequency of a sine wave in Hertz. Since there are 2π radians in a cycle, and Hz is cycles/s, the relationship between frequency in Hertz and angular frequency in radians/s is as follows: An equivalent form of the sine function, and one that is often used, is expressed in terms of angular frequency, ω, measured in units of radians/s rather than Hertz. In the equation y = Asin(2πfx + θ), frequency f is assumed to be measured in Hertz. We suggest Octave as a free alternative that can accomplish some, but not all, of the examples in remaining chapters.īefore we begin working with MATLAB, let’s review the basic sine functions used to represent sound. In future chapters, we’ll limit our examples to MATLAB because it is widely used and has an extensive Signal Processing Toolbox that is extremely useful in sound processing. We introduce you briefly to Octave in Section 2.3.5. If you aren’t able to use MATLAB, which is a commercial product, you can try substituting the freeware program Octave. This will get you started with MATLAB, and you can explore further on your own. In this section, we’ll introduce you to the basic functions that you can use for your work in digital sound. Working with sound in MATLAB helps you to understand the mathematics involved in digital audio processing. If you learn just a few of MATLAB’s built-in functions, you can create sine waves that represent sounds of different frequencies, add them, plot the graphs, and listen to the resulting sounds. ![]() It’s easy to model and manipulate sound waves in MATLAB, a mathematical modeling program.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |