sinusoid | R Documentation |
Create and display one or more sinusoids.
sinusoid (freqs, amps = rep(1, length(freqs)), dur = 50,
phases = rep(0, length(freqs)), fs = 10000, sum = FALSE,
show = FALSE, colors = NULL)
freqs |
A vector of frequencies, one for each desired sinusoid. |
amps |
A vector of peak amplitudes, one for each desired sinusoid. |
dur |
The desired duration of the sinusoids, in milliseconds. |
phases |
A vector of initial phases, one for each desired sinusoid, expressed in radians. |
fs |
The desired sampling frequency of the sinusoids. |
sum |
If TRUE, the sum the generated sinusoids is also found. |
show |
If TRUE, the generated sinusoids are plotted. If sum is TRUE, a second plot is created to display the sum of the sinusoids. |
colors |
An optional vector of colors used to plot the individual sinusoids. If the number of colors given is less than the number of frequencies specified, the colors are repeated. |
A number of sinusoids are generated, and optionally plotted and/or returned. The number of frequencies specified must equal the number of amplitudes and initial phases.
A dataframe with the following columns:
time |
The time, in milliseconds, at which is sample is taken. |
waveN |
A series of columns, each indicating the amplitude of wave N at a given time. |
sum |
A column indicating the sum of all of the sinusoids. |
Santiago Barreda <sbarreda@ucdavis.edu>
## several waves, and the sum
#sum = sinusoid (freqs = c(100,200,300), amps = c(1,3,2),
#sum = TRUE, show = TRUE)
## no sum, different phase shifts
#nosum = sinusoid (freqs = c(100,200,300), amps = c(1,3,2),
#phases = c(pi/2, 0, pi/4), sum = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.