matlab中的傅里叶级数和相移

时间:2016-01-29 07:42:44

标签: matlab fft

我对傅立叶系列有一般性质疑:

假设F和G是非线性相关的两个函数,例如,如果G已知,则可以得到F;并假设我可以用G计算F并得到F和G的傅里叶展开,如下所示。

F = a1*cos(w*t)+b1*sin(w*t)+a3*cos(3*w*t)+b3*sin(3*w*t);

G = c1*cos(w*t)+d1*sin(w*t)+c3*cos(3*w*t)+d3*sin(3*w*t);

我的问题是我们如何在MATLAB中以数字方式将相移(phi)应用于F?如何找到G中的相移,因为F和G是相关的?如果你能解释一个例子我很感激。

感谢您的时间。

1 个答案:

答案 0 :(得分:0)

I found an example very helpful to understand, which answers my question.

I found it online but I can not find it now. Once I do I will post the link here. I hope it will help others too, so here it is:

m = 11 ; 
N_time = (2^m);
w_1 = 0.0307;
T = 2*pi/w_1 ;
Dt = T/2^m;
ffreq = 2*pi/T ; % fundamental frequency
t = linspace(0,T,N_time+1) ;
f = [];
for tk=t
if tk<20
x = 5 ;
f = [f,x] ;
elseif tk<80
x = tk/4*cos(2*pi*tk/20);
f = [f,x] ;
else
x = -tk/10+28 ;
f = [f,x] ;
end
end
fhat = f ;
fhat(1) = (f(1)+f(N_time+1))/2 ;
fhat(N_time+1) = [] ;
F = fft(fhat,N_time) ;
F_0 = F;
F=F(1:N_time/2) ;
k=0:(N_time/2-1) ;
omega=k*ffreq ; % rads/sec
A = 2*real(F)/N_time ;
A(1)= A(1)/2 ;
B =-2*imag(F)/N_time ;
figure;
plot(t, f,'b'); hold on;
plot(t(2:end), real(ifft(F_0)),'--r');

L = 30 ; 
fapprox = A(1)*ones(size(t));
for k=1:L
fapprox = fapprox + A(k+1)*cos(omega(k+1)*t)...
+ B(k+1)*sin(omega(k+1)*t);
end

figure;
plot(t, f,'-b','linewidth',2); hold on; axis tight;
plot(t, fapprox,'--r','linewidth',2);