function out = Xode(t,c) global n2 N D a b % reconstruct u uf = [0 ; -flipud(c(2:end)) ; c]; u2 = ifft(fftshift(-i*uf))*N; u = real(u2(1:N)); % calculate spectral forcings f = (a - b*u.^2).*u; f2 = [f ; 0 ; -flipud(f(2:end))]; ff = -imag(fftshift(fft(f2))/N); cf = ff(N+1:2*N); out = -D*(n2.*c) + cf;