Hello all
I was wondering if someone could help me with a problem I am trying to work out. I am trying to explore certain parameters of an RF amplifier by using Matlab to model certain behaviours so that I can then plan for certain parameters when it comes to designing the amplifier for real.
My current code (see below) has an input signal comprised of two tones that I am then passing through the Rapp model with two different values for the Osat parameter that I can then compare. I am then looking at the fft output by generating two fft plots of the different Osat values for comparison.
I now need to look at varying the amplitude of the input signal then build up a table for the fft magnitude of the output intermod products and fundamental level and so that I can look for when 1dB compression starts. I can then calculate the value of OIP3 which will be helpful for my eventual design.
The problem I have is that I am not sure what commands I need in order to have a varying input amplitude or how to build up a table and I can't seem to find a suitable way of doing this using the Matlab help files.
The following is the code I have so far based on the two tone input signal:
f1 = 200000; %input frequency 200kHz
f2 = 150000; %second tone frequency 150kHz
fs = 50*f1; %sampling frequency
Ta = 1/f1; %input frequency period
Ts = 1/fs; %sampling frequency period
t = (0:Ts:50000*Ta); %timing and step size
input = 1*cos(2*pi*f1*t + 0.5) + 1*cos(2*pi*f2*t + 1); %input signal
u = input; %magnitude value in RAPP model equation
s = 1; %smoothness factor
Osat1 = 0.5; %output saturation factor 1
Osat2 = 1.5; %output saturation factor 2
Fam1 = u./((1+(u./Osat1).^(2*s)).^(1/(2*s))); %RAPP model equation for Osat1
FAM1 = fft (Fam1); %fft of Fam1
X_mag1 = abs (FAM1); %returns absolute values without the complex part of FAM1 fft
binwidth = fs/length(FAM1); %converts x-axis to Hz
xaxis = 0:1:length(FAM1)-1; %converts x-axis to Hzxaxis = xaxis * binwidth; %converts x-axis to Hz%figure (10);
%plot(xaxis,X_mag1);
%hold on
Fam2 = u./((1+(u./Osat2).^(2*s)).^(1/(2*s))); %RAPP model equation for Osat2
FAM2 = fft (Fam2); %fft of Fam2
X_mag2 = abs (FAM2); %returns absolute values without the complex part of FAM2 fft
binwidth = fs/length(FAM2);xaxis = 0:1:length(FAM2)-1;xaxis = xaxis * binwidth;%plot(xaxis,X_mag2);
subplot (2,1,1), plot(xaxis, X_mag1);title('FFT Plot of Osat=0.5')xlabel('Frequency (Hz)')ylabel('Amplitude (dB)')subplot (2,1,2), plot(xaxis, X_mag2);title('FFT Plot of Osat=1.5')xlabel('Frequency (Hz)')ylabel('Amplitude (dB)')
I'm not sure I have managed to convert the axis to MHz correctly either as the plots show 1 to 10 with a 10^6 multiplier but I was trying to have it displayed in something more readable, say 100's of MHz instead.
I also seem to have a problem with converting the y-axis to dB's. Is it just a case of using 20log to change the units for this?
Any help with this would be greatly appreciated.
Regards
Dan
Best Answer