# Alternative Mathematics using MATLAB 7

### Gunnar Backstrom (view profile)

13 Mar 2003 (Updated )

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

ex254.m
```% ex254.m:  Transform of a Sine Function
clear all
ns=1001;  A=1;  nu0=2.0;  a=1/nu0/2;  w0=2*pi*nu0;
tlim=2*a;
dt=2*tlim/(ns-1); 									% Time increment
T=-tlim:dt:tlim ;         							% Sample points, input variable
F=A*sin(w0*T).*unitpulse(T, -a, a);     		% One period only
figure(1),  plot(T,F),  grid on, zoom on	% Show input function
xlabel('time t'),  ylabel('function f(t)'),  axis([-tlim tlim get(gca,'Ylim')])
Nu=linspace(0, 12, 100);						% Frequencies
G=sft(T, F, Nu);   								% Simple Fourier transform
W=2*pi*Nu;										% Angular frequency
Gex=A*( sin(a*(W+w0))./(W+w0)- sin(a*(W-w0))./(W-w0));
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')])
```