📄 createnpsk.m
字号:
function [y, t, v, P] = CreateNPSK(NPSK, fc, amp, fs, RB, M)
% 产生PSK信号,其中NPSK为进制数,典型的为2、4、8等,fc为载波频率,amp为载波基准幅度, fs为采样频率, RB为码元速率
% 载波为 c = amp*sin(2*pi*fc*t);
% y返回已调信号,t为时间矢量,v为码元矢量, P为采样信号的平均功率
% [y, t, v] = Create2ASK(fc, fs, N), 其中M为信息码元数,随机产生N个码元;
% [y, t, v] = Create2ASK(fc, fs, V), 其中V为给定的码元序列,为行矢量;
if (length(M) == 1)
N = M;
V = randint(1, N, NPSK);
else
V = M;
N = length(V);
end;
v = V;
TotalTime = 1/RB * N; %总时间
ts = 1 / fs; %采样周期
index = 1;
curTime = 0;
while(1)
symbIndex = floor(curTime * RB) + 1; %码元序号
if (symbIndex > N)
break;
end
symb = V(symbIndex); %码元符号
y(index) = amp * cos(2*pi*fc*curTime + 2*pi/NPSK * symb + pi/NPSK); %调制过程,产生已调信号瞬时幅度
t(index) = curTime;
curTime = curTime + ts;
index = index + 1;
if (curTime > TotalTime)
break;
end;
end;
P = mean(abs(y).^2);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -