Help to plot a frequency response of a function

I need to plot the following S21 function:
S11= 1/(2RojωC -1)
S21 = Ro/((-1/jωC)+Ro) * (1+S11)
I then need to plot the following S21 function:
S11= -RojωC/(RojωC-2)
S21= 1+ S11
The above euqations need to have:
C = 1.5pF
Ro = 50Ω
ω = 2π*(0GHz to 20GHz)
Intervals: 0.1 GHZ
x axis = Freqency
y axis = dB

3 Comments

hello
what have you tried so far ?
I have an understanding of what might be needed by reviewing https://uk.mathworks.com/help/matlab/ref/plot.html but not much else. It's probably quite an easy task when you know how. I feel like the functions I have are on the correct path but not much ellse. Thanks for help in advance
s=2*pi*(i)
%need "for loop" or similar to increase i from 0 to 20*10^9 in 0.1*10^9
%steps
%need to plot each s21 at each stage of "i"
s11_0 = 1/(2*50*s*(1.5*10^-12)-1)
s21_0 = 50/((-1/s(1.5*10^-12))+50) * (1+S11)
plot(s21_0)
S11_1= -50*s*(1.5*10^-12)/(50*s*(1.5*10^-12)-2)
S21_1= 1 + S11
plot(s21_1)
It's doesn't have to be 0.1 steps, it can be continuous if that's an option

Sign in to comment.

 Accepted Answer

Here is a basic approach (not using any toolbox functions for frequency response), that might give you some ideas of how this can be done in MATLAB
% parameters
C = 1.5e-9 % [Farads]
Ro = 50 % [Ohms]
fRange = [0 20e9] % [frequency range Hz]
interval = 0.1e9 % [plotting interval]
% create vector of frequency values to be evaluated
f = fRange(1):interval:fRange(2)
% convert to radian frequency
omega = 2*pi*f;
j = 1i; % define j (just in case j is used somewhere else as an index)
% evaluate functions at each frequency (vectorized)
S11 = 1.0 ./(2*Ro*j*omega*C -1);
S21 = Ro ./((-1.0 ./(j*omega*C))+Ro) .* (1+S11);
% find the magnitude of S21 and convert to dB
dB = 20*log10(abs(S21));
% plot results
plot(f,dB)
xlabel('frequency [Hz]')
ylabel('S21 [dB]')
Here is what running this code will give you
% parameters
C = 1.5e-9 % [Farads]
C = 1.5000e-09
Ro = 50 % [Ohms]
Ro = 50
fRange = [0 20e9] % [frequency range Hz]
fRange = 1×2
1.0e+10 * 0 2.0000
interval = 0.1e9 % [plotting interval]
interval = 100000000
% create vector of frequency values to be evaluated
f = fRange(1):interval:fRange(2)
f = 1×201
1.0e+10 * 0 0.0100 0.0200 0.0300 0.0400 0.0500 0.0600 0.0700 0.0800 0.0900 0.1000 0.1100 0.1200 0.1300 0.1400 0.1500 0.1600 0.1700 0.1800 0.1900 0.2000 0.2100 0.2200 0.2300 0.2400 0.2500 0.2600 0.2700 0.2800 0.2900
% convert to radian frequency
omega = 2*pi*f;
j = 1i; % define j (just in case j is used somewhere else as an index)
% evaluate functions at each frequency (vectorized) note ./, .* for element
% wise operations
S11 = 1.0 ./(2*Ro*j*omega*C -1);
S21 = Ro ./((-1.0 ./(j*omega*C))+Ro) .* (1+S11);
% find the magnitude of S21 and convert to dB
dB = 20*log10(abs(S21));
% plot results
plot(f,dB)
xlabel('frequency [Hz]')
ylabel('S21 [dB]')

5 Comments

Also if you need a quick overall introduction to MATLAB and haven't already done so I recommend taking the MATLAB "On-Ramp" https://www.mathworks.com/learn/tutorials/matlab-onramp.html
Fantastic. Thank you Jon. MATLAB is a great tool when you know how to use it. I will defintely try that tutorial when I have some tome
Glad that helped. If that answered your question please accept the answer so that others will know that an answer is available
If I want to turn the x axis into a log scale, how do I do that?
You can use semilogx for this. A quick way to see the documentation for functions is to type on the command line doc followed by the name of the command. So in this case type on the command line doc semilogx, and you will get all of the details on how to use the function.

Sign in to comment.

More Answers (0)

Products

Asked:

on 5 Dec 2022

Commented:

Jon
on 8 Dec 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!