⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 amp_distort.m

📁 Matlab simulate AMP.It covers that the source code and how to compile it
💻 M
字号:
fclock = 25*1.28;	%clock rate
fc = 6.6;			%centre frequency
Nc = 3;				%number of carrier

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% get AM/AM and AM/PM measurements, data: Pin, re., imag.
%FileName='H:\Aktuelle_Projekte\Palace\Matlab\60c.asc'
FileName='60c.asc'
z = fopen(FileName,'r');
% first 14 lines are comments
line = char(fgetl(z),fgetl(z),fgetl(z),fgetl(z),fgetl(z),fgetl(z),fgetl(z), ...
				fgetl(z),fgetl(z),fgetl(z),fgetl(z),fgetl(z),fgetl(z),fgetl(z)) ;
Amp_log = (fscanf(z,'%E ; %f ; %f',[3, inf]));
fclose(z);

% get input data
load carriers
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%get linear values
Amp = [10.^(Amp_log(1,:).'/20) 10.^(Amp_log(2,:).'/20)+j*10.^(Amp_log(3,:).'/20)].';

%plot amplifier
figure(1)
subplot(2,1,1);
plot(20*log10(Amp(1,:)), 20*log10(real(Amp(2,:))));
ylabel('Re. Pout [dB]')
xlabel('Pin [dB]')
grid on

subplot(2,1,2);
plot(20*log10(Amp(1,:)), 20*log10(imag(Amp(2,:))));
ylabel('Imag. Pout [dB]')
xlabel('Pin [dB]')
grid on

figure(2)
subplot(2,1,1);
plot(20*log10(Amp(1,:)), 20*log10(abs(Amp(2,:))));
ylabel('Abs. Pout [dB]')
xlabel('Pin [dB]')
grid on

subplot(2,1,2);
plot(20*log10(Amp(1,:)), 180/pi*angle(Amp(2,:)));
ylabel('Angle Pout [癈]')
xlabel('Pin [dB]')
grid on


%plot Td-SCDMA data
figure(3);
CARRIERS = abs(fft(carriers))/length(carriers);
f = fclock*(1:length(carriers))/length(carriers);
plot(f, 20*log10(CARRIERS+10^-6));
title('Spectrum of TD-SCDMA carrier');
%axis([0, max(f), -100, 0]);
xlabel('f [MHz]')
Zoom on


% calculates ACP
f = fclock*(1:length(carriers))/length(carriers);
CHP_index = (max(find(f < fc-0.64)):min(find(f > fc+0.64)));
CHP = 1/length(CHP_index)*sum(CARRIERS(CHP_index).^2);
fprintf('\nCHP = %2.0f dB', 10*log10(CHP));

% calculates ACP
ACP_index = (max(find(f < fc-0.64+3.2)):min(find(f > fc+0.64+3.2)));
ACP = 1/length(ACP_index)*sum(CARRIERS(ACP_index).^2);
fprintf('\nACP = %2.0f dB\n', 10*log10(ACP/CHP));

ACP_index = (max(find(f < fc-0.64+4.8)):min(find(f > fc+0.64+4.8)));
ALT1 = 1/length(ACP_index)*sum(CARRIERS(ACP_index).^2);
fprintf('ALT1 = %2.0f dB\n', 10*log10(ALT1/CHP));

ACP_index = (max(find(f < fc-0.64+6.4)):min(find(f > fc+0.64+6.4)));
ALT2 = 1/length(ACP_index)*sum(CARRIERS(ACP_index).^2);
fprintf('ALT2 = %2.0f dB\n', 10*log10(ALT2/CHP));

%calculate AM/AM and AM/PM
carriers_amp = zeros(size(carriers));
for n=1:length(carriers)
   Indices = find(abs(Amp(1,:)) >= abs(carriers(n)));
   carriers_amp(n)=carriers(n)*Amp(2,Indices(1));
end

%plot data
figure(4);
CARRIERS = abs(fft(carriers_amp))/length(carriers);
f = fclock*(1:length(carriers))/length(carriers);
plot(f, 20*log10(CARRIERS+10^-6));
title('Spectrum of TD-SCDMA carrier');
%axis([0, max(f), -100, 0]);
xlabel('f [MHz]')
Zoom on


% calculates ACP
f = fclock*(1:length(carriers))/length(carriers);
CHP_index = (max(find(f < fc-0.64)):min(find(f > fc+0.64)));
CHP = 1/length(CHP_index)*sum(CARRIERS(CHP_index).^2);
fprintf('\nCHP = %2.0f dB', 10*log10(CHP));

% calculates ACP
ACP_index = (max(find(f < fc-0.64+3.2)):min(find(f > fc+0.64+3.2)));
ACP = 1/length(ACP_index)*sum(CARRIERS(ACP_index).^2);
fprintf('\nACP = %2.0f dB\n', 10*log10(ACP/CHP));

ACP_index = (max(find(f < fc-0.64+4.8)):min(find(f > fc+0.64+4.8)));
ALT1 = 1/length(ACP_index)*sum(CARRIERS(ACP_index).^2);
fprintf('ALT1 = %2.0f dB\n', 10*log10(ALT1/CHP));

ACP_index = (max(find(f < fc-0.64+6.4)):min(find(f > fc+0.64+6.4)));
ALT2 = 1/length(ACP_index)*sum(CARRIERS(ACP_index).^2);
fprintf('ALT2 = %2.0f dB\n', 10*log10(ALT2/CHP));



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -