clc
clear all
close all
in5=importdata('sin.coe'); %% 导入波形数据
qn=importdata('square.coe');
Fs = 245760000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 100000; % Length of signal
t = (0:L-1)*T; % Time vector S(nTs)
%% 两倍上采样
in1=zeros(2*length(in5),1);
in1(1:2:length(in1))=in5;%二倍上采样,内插零值
qn1=zeros(2*length(qn),1);
qn1(1:2:length(qn1))=qn;%二倍上采样,内插零值
%% 滤除镜像分量
b=2*fir1(62,1/2);%滤除镜像分量的滤波器
in2=conv(b,in1);
in3=in2(1:L);
qn2=conv(b,qn1);
qn3=qn2(1:L);
%% 正交调制
dds_cos= [round(1024*cos(2*pi*61440000*t))]';
dds_sin= [round(1024*sin(2*pi*61440000*t))]';
o_duc_modulate=dds_cos.*in3-dds_sin.*qn3;
% figure;subplot(211);
% plot(Fs*t,o_duc_modulate);%画图按照n来画,所以*Fs
% axis([0 600 -2000000 2000000]);
% title('y(n)时域波形')
% xlabel('n')
% ylabel('y(n)')
%
% [Yf, f] = Spectrum_Calc(o_duc_modulate, Fs);
% subplot(212)
% plot(f,Yf)
% title('频谱')
% xlabel('f (Hz)')
% ylabel('|Yf(f)|')
% HammingWin=window('hamming',L); %加汉明窗?减少时域突然截断带来的影响,减少频谱泄露
% xn=xn.*HammingWin;
% plot(f,magH);grid on
% title('频谱分析');
% xlabel('频率/Hz ');
% ylabel('幅度/V ');
%% DAC
%
% fc = 2.015 * 10 ^ 9; % RF频段 2015MHz
% Carr_real=[];
% Carr_imag=[];
% Carr = [];
% for n=1:length(ofdm_signal)
% Carr_real = real(ofdm_signal(n))*cos(2*pi*fc*t); %modulate the real part on a cosine carrier
% Carr_imag = imag(ofdm_signal(n))*sin(2*pi*fc*t); %modulate the imaginary part on a sine carrier
%% DUC RF=2015MHz
%RF_cos= [round(1024*cos(2*pi*2015000000*t))]';
%o_duc_modulate_RF=o_duc_modulate_DAC.*RF_cos;
%% DDC
%o_duc_modulate_ADC=o_duc_modulate_RF.*RF_cos;
%% ADC
%% 正交解调
in4=o_duc_modulate.*dds_cos;
qn4=o_duc_modulate.*dds_sin;
%% 抗混叠滤波器
b1=1*fir1(62,1/2);
in5=conv(in4,b1);
qn5=conv(qn4,b1);
%% 两倍下采样
in6=in5(1:2:length(in5));
qn6=qn5(1:2:length(qn5));
hn=importdata('fir.coe');
in7=conv(in6,hn)
figure;plot(in7);axis([0 1000 -600000000 600000000]);
qn7=conv(qn6,hn)
figure;plot(qn7);axis([0 1000 -700000000 700000000]);
- 1
- 2
前往页