xvals<-1:100 y<-20*cos(2*pi*0.05*xvals)+cos(2*pi*0.15*xvals) n<-length(y) I1<-abs(fft(y)/sqrt(n))^2 P1<-I1*4/n par(mfrow = c(2, 1)) par(mar = c(5, 5, 1, 1)) plot(P1[1:51], type = "l", xlab = "Frequency", ylab = "", lwd = 3, xaxt = "n", yaxt = "n", cex.lab = 1.6) axis(1, at = seq(0, 50, by = 10), labels = seq(0, 0.5, by = 0.1), cex.axis = 1.4) axis(2, at = seq(0, 400, by = 200), labels = seq(0, 400, by = 200), cex.axis = 1.4) plot(log10(P1[1:51]), type = "l", xlab = "Frequency", ylab = "", lwd = 3, xaxt = "n", yaxt = "n", cex.lab = 1.6) axis(1, at = seq(0, 50, by = 10), labels = seq(0, 0.5, by = 0.1), cex.axis = 1.4) axis(2, at = seq(-30, 0, by = 10), labels = seq(-30, 0, by = 10), cex.axis = 1.4) dev.print(device = postscript, "18.13.eps", horizontal = TRUE)