How do i convert randint function to randi function using Matlab

12 views (last 30 days)
My code below is FSK Modulation: When i use randint,Matlab says Warning: This is an obsolete function and may be removed in the future. Please use RANDI instead. In randint at 41 In fskm at 3.How can i fix this
%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;

Answers (1)

Andrei Bobrov
Andrei Bobrov on 15 Oct 2018
b=randi([0,1],1,n);

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!