我下面的代码是FSK调制: 当我使用randint时,Matlab会警告:这是一个过时的功能,将来可能会删除。请改用RANDI。 在randint,41岁 在3的fskm中 我该如何解决
%1. Generating a random bit sequence as the information signal.
n=100000;
b=randint(1,n);
%2.FSK
%2.1 Defining parameters
f1=2; %2.1 Carrier frequency for 0
f2=5; %2.2 Carrier frequency for 1
t=0:1/30:1-1/30; %2.3 Time period
sf0=sin(2*pi*f1*t); %2.4 Carrier signal for 0
E=sum(sf0.^2); %2.5 Energy of Carrier signal for 0
sf0=sf0/sqrt(E); %2.6 Carrier signal to be transmitted for 0
sf1=sin(2*pi*f2*t); %2.7 Carrier signal for 1
E=sum(sf1.^2); %2.8 Energy of Carrier signal for 1
sf1=sf1/sqrt(E); %2.9 Carrier signal to be transmitted for 1
%2.2 FSK MODULATION
%Modulating the random bit sequence using a simple for loop
fsk=[];
for i=1:n
if b(i)==1
fsk=[fsk sf1];
else
fsk=[fsk sf0];
end
end
%2.3 FSK Plots
%2.3.1 Information Bits
figure(1);
subplot(411);
stairs(0:10,[b(1:10) b(10)],'linewidth',1.5);
axis([0 10 -0.5 1.5]);
title('Information Digital Signal');grid on;
tb=0:1/30:10-1/30;
%2.3.2 Modulated Signal
subplot(413);
plot(tb, fsk(1:10*30),'r','linewidth',1.5);
title('FSK Modulated Signal');
grid on;
答案 0 :(得分:0)
根据我通过Google找到的a copy of old documentation,
b=randint(1,n);
将生成一个1
x n
矩阵,该矩阵填充有0和1,每一个的概率为0.5。这与:
b = randi([0,1],1,n);
(请参阅the docs to randi
)。
相关: