www.gusucode.com > rf 案例源码程序 matlab代码 > rf/ComputeAndPlotTimeDomainResponseExample.m
%% Compute Transmission Line Transfer Function and Time Domain Response % This example shows %% Build a transmission line % % Copyright 2015 The MathWorks, Inc. tline = rfckt.parallelplate('LineLength',0.1,'Width',0.05); %% Define range of frequencies to analyze the transmission line % f = [1.0e9:1e7:2.9e9]; analyze(tline,f); %% Extract S-parameters of the tx line % [S_Params, Freq] = extract(tline,'S_Parameters'); %% Compute the transfer function of the tx line % TrFunc = s2tf(S_Params); %% Fit rational function to the computed data % RationalFunc = rationalfit(Freq,TrFunc) %% Compute the frequency response [fresp,freq] = freqresp(RationalFunc,Freq); %% Plot the amplitude of the frequency response of the fitted model data and computed data % figure plot(freq/1e9,20*log10(abs(fresp)),freq/1e9,20*log10(abs(TrFunc))) xlabel('Frequency, GHz') ylabel('Amplitude, dB') legend('Fitted Model Data','Computed Data') %% Plot the angle of the frequency response of the fitted model data and computed data % figure plot(freq/1e9,unwrap(angle(fresp)),... freq/1e9,unwrap(angle(TrFunc))) xlabel('Frequency, GHz') ylabel('Phase Angle, radians') legend('Fitted Data','Computed Data') %% Create random input signal % SampleTime = 1e-12; NumberOfSamples = 1e4; OverSamplingFactor = 25; InputTime = double((1:NumberOfSamples)')*SampleTime; InputSignal = ... sign(randn(1, ceil(NumberOfSamples/OverSamplingFactor))); InputSignal = repmat(InputSignal, [OverSamplingFactor, 1]); InputSignal = InputSignal(:); [tresp,t] = timeresp(RationalFunc,InputSignal,SampleTime); %% Plot the time response % figure plot(t,tresp) xlabel('Time (seconds)') ylabel('Response to Random Input Signal')