I've created a signal by adding a sine wave and a cosine wave using
# number of samples N <- 1000 # time period TT <- 2 # sampling frequency (number of samples by unit of time) fs <- N / TT # vector of sampling time points stp <- seq(from=0, to=TT - 1 / fs, by=1 / fs) # 2 Hz sine wave with peak amplitude 2 sn1 <- 2 * sin(2 * pi * 2 * stp) # 5 Hz cosine wave with peak amplitude 3 sn2 <- 3 * cos(2 * pi * 5 * stp) # input signal sn <- sn1 + sn2
Using the Fourier transform, I can see that the signal is made up of two waves with amplitudes 2 and 3 and frequencies 2 and 5, respectively.
fou <- fft(sn) N <- length(fou) fou <- fou[2:((N / 2) + 1)] freq <- (1:(N / 2)) / TT ampl <- Mod(fou) / length(fou) plot(freq, ampl)
Question: How do I know that the wave with frequency 2 is a sine wave and that the wave with frequency 5 is a cosine wave?