# Phase shift of transfer function using MATLAB

I'm trying to compute the phase shift of a transfer function (accelerance) in MATLAB, but I'm having issues.

The transfer function was computed by dividing the magnitude of the system output by the input (please see here).

I've been using pwelch() to compute all of the functions in the frequency domain, but from the best of my understanding, the Welch PSD estimate outputs a real-valued vector, so there's no way to get a phase shift.

When I try to use the fft() function, the result (magnitude) doesn't look right, so I'm not sure if I would trust the phase shift. Below is the code I used to compute the transfer function:

% Welch Acceleration
[pa,f] = pwelch(ay,1000,10,0:10:10000,Fs);
% Welch Force
[pf,f] = pwelch(fy,1000,10,0:10:10000,Fs);
% Transfer function
H = pa./pf;


If someone could point me in the right direction it would be appreciated.