y(t)=|t|, y(t+2π)=y(t) のフーリエ級数展開。(周期T=2π)
固有周波数f0=1/T。
以下のようにフーリエ級数展開するとき、
係数は以下のように計算される。
clear; close all; clc; f = @(t) abs(t); T=2*pi; f0=1/T; dt=0.01; t=-T/2:dt:T/2; y=f(t); plot(t,y,'r','DisplayName','original'); hold on; a0=T/2; a=@(n) 4/T*((-1)^n-1)/(2*pi*f0*n)^2; b=@(n) 0; % nmax=10; ns=[1,3,5]; for idx=1:length(ns) nmax = ns(idx); yt=fourier_series(t,f0,a0,a,b,nmax); plot(t,yt,'--','DisplayName',sprintf('N=%d',nmax)); end legend(); xlim([-1,1]); big; function ft=fourier_series(t,f0,a0,a,b,nmax) ft = a0/2; for n=1:nmax an = a(n); bn = b(n); ft = ft + an*cos(2*pi*f0*n*t) + bn*sin(2*pi*f0*n*t); end end
