periodify | R Documentation |
Adds an integer no. of periods of the X-Y dataset to itself.
The no. of integer periods by which the X-Y dataset is increased in the forward and backward direction is specified by "fwd" and "bwd" arguments.
Hence, if L is the length of the X-Y dataset, the new dataset has a length of "L*(fwd + bwd + 1)".
The returned dataset is always a dataframe
periodify(X, Y, fwd, bwd)
X |
An atomic numeric vector X signifying the X-axis of the dataset |
Y |
An atomic numeric vector Y signifying the Y-axis of the dataset |
fwd |
A single whole number or integer specifying the no. of periods by which to increase the span of the dataset in the forward direction |
bwd |
A single whole number or integer specifying the no. of periods by which to increase the span of the dataset in the backward direction |
The returned datatype is always a 2 column dataframe with the new X and Y vectors contained in it and named as "X" and "Y respectively"
Can be used to increase the resolution of a DFT(Discrete Fourier Transform). See examples.
Chitran Ghosal
library(StatsChitran)
##define the datasets
X <- seq(0, 2*pi, by = 0.1)
Y <- sin(X)
subplot(c(2, 2)) #divide the plotting screen
plot(X, Y, type = 'l', col = 'gray', lwd = 2, main = 'original') #plot the basic dataset
ft_XY <- ft(X, Y, w = T, set.nyquist = T) #fourier transform of the original dataset
plot(ft_XY$wf, abs(ft_XY$fy), type = 'b', col = 'red', xlim = c(-10, 10), main = 'original fft') #plot the amplitude function of the original dataset
df <- periodify(X, Y, fwd = 1, bwd = 2) #use the periodify function to build a dataset df
plot(df$X, df$Y, type = 'l', col = 'gray', lwd = 2, main = 'new dataset') #plot the new dataset
ft_df <- ft(df$X, df$Y, w = T, set.nyquist = T) #fourier transform of the new dataset
plot(ft_df$wf, abs(ft_df$fy), type = 'b', col = 'red', xlim = c(-10, 10), main = 'new fft') #plot the amplitude function of the new dataset
subplot(c(1, 1)) #return to the original screen
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.