Displaying 1 result from an estimated 1 matches for "pk5".
Did you mean:
k5
2011 Jul 27
2
fitting sine wave
...8,-0.1265754)
x <- c(1,2,3,4,5,6,7)
p <- nls(m~k1*x+k2*cos(x)+k3*sin(x)+k4*cos(2*x)+k5*sin(2*x)+k6*cos(3*x),start = list(k1=0,k2=0,k3=0.1,k4=0.1,k5=0,k6=0))
par ?<- c(pk1=summary(p)$parameters[1,1],pk2=summary(p)$parameters[2,1],pk3=summary(p)$parameters[3,1],pk4=summary(p)$parameters[4,1],pk5=summary(p)$parameters[5,1],pk6=summary(p)$parameters[6,1])
xx <- seq(1,7,length.out=500)
mm <- par[1]*xx+par[2]*cos(xx)+par[3]*sin(xx)+par[4]*cos(2*xx)+par[5]*sin(2*xx)+par[6]*cos(3*xx)
plot(x,m)
points(xx,mm,type="l")
?
I was also thinking of using fft(), but when I use the inverse...