close all clear all clc load('exercise2.mat') % defines t, x, T N = length(x); X = fftshift(T*fft(x)); om = (-round((N-1)/2):round(N/2)-1) *2*pi/(N*T); figure subplot(2,1,1) plot(t,x) grid xlabel('t') ylabel('x(t)') title('signal') subplot(2,1,2) semilogy(om,abs(X)) grid xlabel('\omega') ylabel('X(\omega)') axis([0 max(om) 1e-3 1e4]) title('Fourier transform') % printing figure in png format set(gcf,'PaperUnits','inches','PaperPosition',[0 0 6 4.5]) print -dpng exercise2.png -r100