N=1024;
fs=1024;
t=0:1/fs:(N-1)/fs;
x=sin(200*pi*t);
%原始波形
figure
plot(t,x)%%%波形
set(gca,'xlim',[0,0.2],'ylim',[-1.3,1.3])
title('原始波形图')
%频谱分析
a=fft(x);
a=abs(a)*2/N;
f=0:fs/N:(N-1)*fs/N;
figure
plot(f,a)
title('幅频谱图')
%逆变换后时域图
b=ifft(a)*N/2;
figure
plot(t,b)
set(gca,'xlim',[0,0.2],'ylim',[-1.3,1.3])
title('反变换后波形')
%首先可以拟合一个函数:x=(heaviside(n)-heaviside(n-4))+
%(heaviside(n+4)-heaviside(n+1))*(2*n+5);
clear
syms n
x=(heaviside(n)-heaviside(n-4))*6+(heaviside(n+4)-heaviside(n+1))*(2*n+5);
n=-10:0.1:10;
xn=subs(x,n);
plot(n,xn)