# Alternative Mathematics using MATLAB 7

### Gunnar Backstrom (view profile)

13 Mar 2003 (Updated )

Self-instructive text on undergraduate algebra, statistics, differential and integral calculus.

ex252.m
```% ex252.m: Fourier Transform of a Rectangular Pulse
clear all
ns=101;                      				% Number of samples
A=1;  a=1e-2;							% Constants for function
tlim=2*a;
dt=2*tlim/(ns-1); 						% Time increment
T=-tlim:dt:tlim ;         				% Sample points, input variable
F=A*unitpulse(T, -a, a);         		% Square pulse
figure(1),  plot(T,F),  grid on		% Show input function
xlabel('time t'),  ylabel('function f(t)'),  axis([-tlim tlim get(gca,'Ylim')])
Nu=linspace(0, 5/a, 100);			% Frequency vector
G=sft(T, F, Nu);   					% Simple Fourier transform
W=2*pi*Nu;							% Angular frequency
Gex=2*A*sin(a*W)./W;				% Exact transform
figure(2),  plot( Nu,real(G),'o', Nu,imag(G),'*', Nu,Gex ),  grid on
xlabel('frequency'), ylabel('Fourier transform: real(g)=o, imag(g)=*')
axis([min(Nu) max(Nu) get(gca,'Ylim')])

```