%exam_8_29
clear;
wf=40;Nf=64;
tend=8;N_time=256;
dt=tend./N_time;t=(1:N_time).*dt;
f=zeros(1,N_time);
f(1,1:N_time/2)=f(1,1:N_time/2)+ones(1,N_time/2);
w_r=linspace(0,wf,Nf);dw=wf/(Nf-1);
F_r=f*exp(-1i*t'*w_r)*dt;
w=[-fliplr(w_r),w_r(2:Nf)];
F=[fliplr(F_r),F_r(2:Nf)];
subplot(1,2,1);
plot(t,f,'linewidth',2),grid on;
set(gca,'Fontsize',20);
ylabel('Amplitude','Fontsize',20);xlabel('Time','Fontsize',20);
axis([0,tend,0,1.1]);
subplot(1,2,2);
plot(w,abs(F),'linewidth',2),grid on;
set(gca,'Fontsize',20);
ylabel('Amplitude','Fontsize',20);xlabel('Frequency(rad/s)','Fontsize',20);





