www.gusucode.com > rf 案例源码程序 matlab代码 > rf/RationalFunctionApproximationofSparameterDataExample.m
%% Rational Function Approximation of S-parameter Data % Fit a rational function object to S-parameter data, and compare the results % by plotting the object against the data. %% % Read the S-parameter data into an RF data object. orig_data = read(rfdata.data,'passive.s2p'); freq = orig_data.Freq; data = orig_data.S_Parameters(1,1,:); %% % Fit a rational function to the data using |rationalfit|. fit_data = rationalfit(freq,data) %% % Compute the frequency response of the rational function using |freqresp|. [resp,freq] = freqresp(fit_data,freq); %% % Plot the magnitude of the original data against the rational function % approximation. $S_{11}$ data appears in blue, and the rational function % appears in red. Scaling the frequency values by |1e9| converts them to % units of GHz. figure title('Rational fitting of S11 magnitude') plot(orig_data,'S11','dB') hold on plot(freq/1e9,20*log10(abs(resp)),'r'); %% % Plot the angle of the original data against the rational function approximation. figure title('Rational fitting of S11 angle') plot(orig_data,'S11','Angle (radians)') hold on plot(freq/1e9,unwrap(angle(resp)),'r')