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

📄 bpsk.m

📁 BPSK信号源matlab代码
💻 M
字号:
% Script file: LFM_Chirp.m
%
% Purpose:
% To calculate and download an arbitrary waveform file that simulates a
% pulsed signal with a linear fm chirp to the PSG vector signal generator.
%
% Record of revisions:
%
% Date Programmer Description of change
% ==== ========== =====================
% 4/15/2002 Randal Burnette Initial version for 2002 AD Symposium
% 8/14/2002 John Hutmacher Added comments and Download Assistant
% 9/4/2002 Randal Burnette Added Preset, turned ALC off, and IQ Scaling
% and corrected fm to pm integration calc
% 6/26/2003 Randal Burnette Added Modulation ON
%
% Define variables:
%
% n -- counting variable (no units)
% ramp -- ramp from -1 to almost +1; used to build sine waves
% rise -- raised cosine pulse rise-time definition (samples)
% on -- pulse on-time definition (samples)
% fall -- raised cosine pulse fall-time definition (samples)
% off -- pulse off-time definition (samples)
% ontime -- total number of points in the rise + on + fall
% i -- in-phase modulation signal (samples)
% q -- quadrature modulation signal (samples)
% IQData -- complex array containing both i and q waveform samples
% Markers -- array containing markers for Event Markers 1 and 2
% am -- amplitude envelope for the pulse, linear units
% pm -- phase of the pulse vs time in rads
% fm -- offset frequency from carrier vs time in Hz
% sampclk -- clock freq for the D/A converters in the IQ modulator
% chirp_dev -- total chirp frequency deviation in Hz
sampclk = 100e6; % defines the ARB Sample Clock for playback
chirp_dev = 10e6; % defines the total chirp deviation in Hz
pw=3010;
pri1=100000;

%n=4; % defines the number of points in the rise-time & fall-time
n=10; 
ramp=-1:2/n:1-2/n; % ramp from -1 to almost +1 over n points
begin=zeros(1,63);
rise=(1+sin(ramp*pi/2))/2; % defines the raised cos rise-time shape
%on=ones(1,92); % defines the on-time characteristics
on=ones(1,10000); 
fall=(1+sin(-ramp*pi/2))/2; % defines the raised cos fall-time shape
off=zeros(1,pri1-10000); % defines the off-time sample points


% concatenate the parts of the amplitude of the pulse into a single array
am = [  on  off];
figure(1);
plot(am);
axis ([0 length(am) -2 2]);
% define an array which contains the the chirp waveform
high=ones(1,40);
low=-ones(1,40);
bark = [ high high high high high low low high high low high low high...
    high high high high high low low high high low high low high...
    high high high high high low low high high low high low high...
    high high high high high low low high high low high low high...
    high high high high high low low high high low high low high...
    high high high high high low low high high low high low high...
    high high high high high low low high high low high low high...
    high high high high high low low high high low high low high...
    high high high high high low low high high low high low high...
    high high high high high low low high high low high low high...
    high high high high high low low high high low high low high...
    high high high high high low low high high low high low high...
    high high high high high low low high high low high low high...
    high high high high high low low high high low high low high...
    high high high high high low low high high low high low high...
    high high high high high ...
     zeros(1,pri1-8000) ];

% fm=(chirp_dev/2)*([-ones(1,n) (-1:2/(length(on)-1):1) ones(1,n) ones(1,length(off))]);
fm=(chirp_dev/2)*([ones(1,pri1) ]);
% fm=(chirp_dev/2)*([ones(1,pri1+pri2]);
% fm=([-ones(1,n) (-1:2/(length(on)-1):1) ones(1,n) ones(1,length(off))]);
% use an integral to translate from fm to pm
pm=(2*pi/sampclk)*cumsum(fm);
% pm=cumsum(fm);
% plot the fm-samples and scale the plot
figure(2);
%plot(fm);
plot(pm);

%axis ([0 length(fm) -10e6 10e6]);
axis ([0 10000 -1000 10000]);

% convert am and pm to i and q and scale amplitude
% i = am.* (bark.* cos(pm));
i = am.* (bark.* cos(pm));
%j = fft(i);
figure(3);
plot(i);
axis([0 length(i) -10 10]);

q = am.* (bark.* sin(pm));
figure(4);
plot(q);
axis([0 length(q) -10 10]);

% define a composite iq matrix for download to the PSG using the
% PSG/ESG Download Assistant
 IQData = [i + (j * q)];
%Y= [i + (j * q)];
 %IQData = AWGN(Y,20,0);
figure(5);
plot(real(IQData));
figure(6);
plot(imag(IQData));
maximum = max( abs(IQData) ); 
 IQData = IQData / maximum;
 
 f=i(1:400);
 figure(7);
 plot(f);
 
 
 Y=fft(IQData(1:8000),256);
N=length(Y);



    figure(8);
 plot(abs(Y));
  xlabel('频率索引值');
  ylabel('幅度');
  grid on;

⌨️ 快捷键说明

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