# Solving linear systems using fourier transform

1. Sep 14, 2012

### jjphys

I want to use Matlab and fourier transforms to solve linear systems and am attempting to implement a very simple linear system (with the idea of implimenting a much more complex one later) that I can't seem to get working. The system will take the derivative with respect to time of the input as follows:

output(t) = (d/dt)*input(t)

Find the transfer function by taking the Fourier transform of both sides and rearranging (F = Fourier transform):

F[ output(t) ] = F[ (dinput/dt ]

F[ (dinput/dt ] = 2*pi*i*f * F[ input(t) ]

therefore:

F[ output(t) ] = 2*pi*i*f * F[ input(t) ]

and our transfer function, F[output(t)] / F[input(t)] = 2*pi*i*f = H(f)

The final system is:

output(t) = F-1[ 2*pi*i*f * F[ input(t) ] ]

The code that I'm implementing in Matlab is posted below seems to work correctly if the input function is sin or cos, but for x2 (which should yield 2x as the output) doesn't work (also note that I'm having some issues with getting scaling right, but I'm not to worried about this at the moment) Any ideas?

Code (Text):

%parameters
L_duration_s=1.0;       %sampling duration, L
N_time_bins=1024;     % # samples
delta_t=L_duration_s/N_time_bins;
time_s=0:delta_t:(N_time_bins-1)*delta_t;
delta_f=1/L_duration_s;
f_ny=(N_time_bins/2)*delta_f;
time_f=-f_ny+(N_time_bins-1)*delta_f:-delta_f:-f_ny;

i_=sqrt(-1);

%pinput waveform
x_t=cos(2*pi*time_s);    %sin->cos
%cos->-sin

%fourier transform of input
x_f=(1/N_time_bins)*fft(x_t);

%xfer function
H_f=(1/N_time_bins)*((2*i_*pi).*time_f);
H_t=ifft(H_f);

%calculation of output
y_f=H_f.*x_f;
y_t=N_time_bins* ifft(y_f);