Digital Sound & Music: Concepts, Applications, & Science, Chapter 2, last updated 6/25/2013

30

fplot('2*sin(262*2*pi*t)', [0, 0.05, -2.5, 2.5]);

After multiplying by A=2 in the statement above, the top of the sine wave goes to 2 rather than 1.

To change the phase of the sine wave, we add a

value

. Phase is essentially a

relationship between two sine waves with the same frequency. When we add

to the sine

wave, we are creating a sine wave with a phase offset of

-2.5,

compared to a sine wave with phase

offset of 0. We can show this by graphing both sine waves on the same graph. To do so, we

graph the first function with the command

fplot('2*sin(262*2*pi*t)', [0, 0.05, 2.5]);

We then type

hold on

This will cause all future graphs to be drawn on the currently open figure. Thus, if we type

fplot('2*sin(262*2*pi*t+pi)', [0, 0.05, -2.5, 2.5]);

we have two phase-offset graphs on the same plot. In Figure 2.31, the 0-phase-offset sine wave

is in red and the

180o

phase offset sine wave is in blue.

Figure 2.31 Two sine waves, one offset

180o

from the other

Notice that the offset is given in units of radians rather than degrees,

180o

being equal to π

radians.

To change the frequency, we change . For example, changing to 440*2*pi gives us a

graph of the note A above middle C on a keyboard.

fplot('sin(440*2*pi*t)', [0, 0.05, -1.5, 1.5]);

The above command gives this graph:

0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0.04 0.045 0.05

-2

-1

0

1

2