Calculate input impedance from S-parameters

I wrote this simple matlab code to calculate input impedance of a low pass filter but not sure whether all the steps are correct. * First attempt

z0           = 50;

A            = importdata("sparameters_lowpass.dat");

freq         = A(:,1);
realPart     = A(:,2);
imagPart     = A(:,3);

s11_freq     = realPart + imagPart*i; % In frequency domain

%X           = fft(s11_freq, N); % Not sure whether this is the right way to interpolate

X            = s11_freq;

X_conj       = conj(flip(X));

X_input      = [X_conj(1:end-1)', X(1), X(2:end)']';

M            = length(X_input);

window       = hamming(M);

s11_time     = ifft(X_input.*window, 1024);

z_in         = z0*(1+ (s11_time))./(1- (s11_time));


• Your data is already in the frequency domain---- it sounds like your challenge is just in how to interpolate your results. To me you are doing a lot more than is needed- I would just compute z_in on the s11_freq data directly and then you can interpolate that using the resample command. – Dan Boschen Feb 11 at 14:00
• The idea is to tune a filter in time-domain just like time domain analysis with Network Analyzer. More over the length of the filter and so on. I myself is rather very new to this... – jomegaA Feb 11 at 14:55
• Well I don’t think you can get there using this approach— the network analyzer will have a resolution bandwidth and sweep rate that will effect the temporal characteristics of your signal (and I assume within the duration of your capture the impedance hasn’t changed). Your measurement of S11 is the static measurement of S11 vs frequency not time. – Dan Boschen Feb 11 at 15:37
• modification to above comment: "...and sweep rate that will effect the measurement of the temporal characteristics of your signal". The network analyzer won't change your signal as my first version of this sentence would literally imply. – Dan Boschen Feb 11 at 17:53
• Since its first project in signal processing after 17 years (some work during University studies) and I have little or no clue on some or many things. But having very good time in reading Classics such as Digital Signal Processing - Proakis. Any recommendation read for Filter Design? – jomegaA Feb 11 at 18:24

S11 is in the frequency domain, and the impedance should also be in the frequency domain. If you want to resample the result, simply use the resample command:

z0           = 50;
A            = importdata("sparameters_lowpass.dat");
N            = 5000;      % number of samples in final result desired

freq         = A(:,1);
realPart     = A(:,2);
imagPart     = A(:,3);

s11_freq     = realPart + imagPart*i; % In frequency domain

z_in         = z0*(1+ (s11_freq))./(1- (s11_freq));

freq_resamp = resample(freq, N)
z_in_resamp = resample(z_in, N)


Note that your formula for S11 would be correct when it is given as a complex signal with a magnitude between 0 and 1 and any phase. Just a word of caution in case the result is in dB magnitude and phase (I don't think that is the case given the extraction of the real and imaginary part shown but that should be confirmed).

• s11 = realPart + imagPart*i; % In frequency domain s11_resamp = resample(s11, N, 1); s11_time_zero_pad = [ifft(s11)' zeros(1,N-length(s11))]; s11_freq_interpol = fft(s11_time_zero_pad); Are they same? Long wonder how to interpolate spectrum without transforming it to time-domain, zero-pad and transform to frequency domain? – jomegaA Feb 17 at 20:19
• They are equivalent and possibly but not necessarily identical. The actual resampling implementation has an interpolation filter and depending on its implementation can change the results (if you are looking for exact equivalence but will generally provide the same result). – Dan Boschen Feb 17 at 21:14
• Is there a way to interpolate a spectrum without transforming the spectrum to TD and zero-pad the signals and transform it back to frequency domain? My gut feeling is not possible* – jomegaA Feb 17 at 21:20
• Yes of course — insert zeros and then use an interpolation filter all from the same domain. There are other posts here on doing just that, that I can point you to – Dan Boschen Feb 17 at 21:25
• Sure. Would like to see those posts. Meanwhile I can also search them. Other obvious questions are how are zero-padding performed on low pass and band pass signal without carrier or rather what has to be considered on performing zero-padding of low-pass and band-pass spectrum without carrier? Zero padding in frequency domain for $N$ even and odd cases are known. – jomegaA Feb 17 at 21:30