makewave: Make wave

Description Usage Arguments Value Note Examples

Description

Generate a vector of numeric data points representing a sine wave

Usage

1
2
makewave(freq, phase, amp, Nsamples = time * samplerate, samplerate,
  time = Nsamples/samplerate, as.time.series = TRUE)

Arguments

freq

The frequency of cycles per unit time (e.g. Hz) of the sine wave

phase

The frequency in degrees of the sine wave

amp

The amplitude of the sine wave

Nsamples

The number of samples to generate, this defaults to the time * sample rate.

samplerate

The number of samples to create per unit of time

time

The number of units of time represented by the generated sine wave

as.time.series

Should the result be returned as a time series ts()

Value

A numeric vector or a time series representing the specified sine wave

Note

coh is calculated as coh[, i + (j - 1) * (j - 2)/2] <- Mod(pgram[, i, j])^2/(spec[, i] * spec[, j]) Mod(pgram[, i, j])^2 #cross-amplitude values

Examples

1
2
3
4
5
6
7
8
plot(makewave(2,0,3.889*1.6,180,60))
sp <- spectrum(ts.union(makewave(15,30,1,180,60),makewave(15.01,60,1,180,60)),span=c(3),taper=0)
with(sp,data.frame(freq=freq,sta.freq=freq/60,phase=round(phase,4),coh=round(coh,4),phase.deg=round(phase/(2*pi)*180,2)))[c(35,45,55),]
plot(sp$freq,sp$phase/(2*pi)*180,type="l")
plot(sp,plot.type="phase")
plot(sp,plot.type="coh")
plot(ts.union(makewave(15,30,1,180,60),makewave(15.01,60,1,180,60)))
Mod(mvfft(ts.union(makewave(15,30,1,180,60),makewave(15.01,60,1,180,60))))

drknexus/repsych documentation built on May 15, 2019, 2:19 p.m.