Hi,
As per my understanding, you want to calculate transfer function a system from its input and output. In general transfer function can be calculated by dividing output of the system in frequency domain by input/excitation given to system in frequency domain. Refer this for better understanding.
-> If only magnitude of input and output in frequency domain is used for calculating transfer function, all the system’s information cannot be understood. So if there is a phase shift between output and input , that is because of the system.
-> "pwelch()" is a power spectral density estimate. As the name suggests, it is always real since power is real . So, by dividing PSD of output with PSD of input may only give the magnitude information of the system.
