0% found this document useful (0 votes)
41 views

'Too Many Input Arguments': %FSK Modulation %example: (f0 and f1 Must Be Integers) %FSKD ( (1 0 1 0 1 0), 1,4)

This MATLAB function performs frequency-shift keying (FSK) modulation. It takes in a binary data sequence, and two integer carrier frequencies. It generates the FSK modulated signal by shifting the carrier frequency between the two values based on the binary input. The function outputs the binary input signal, the modulated carrier signal, and the FSK modulated output signal in two subplots for visualization.

Uploaded by

nasty boy
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

'Too Many Input Arguments': %FSK Modulation %example: (f0 and f1 Must Be Integers) %FSKD ( (1 0 1 0 1 0), 1,4)

This MATLAB function performs frequency-shift keying (FSK) modulation. It takes in a binary data sequence, and two integer carrier frequencies. It generates the FSK modulated signal by shifting the carrier frequency between the two values based on the binary input. The function outputs the binary input signal, the modulated carrier signal, and the FSK modulated output signal in two subplots for visualization.

Uploaded by

nasty boy
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

function fsk(g,f0,f1)

%FSK modulation
%Example:(f0 and f1 must be integers)
%fskd([1 0 1 0 1 0],1,4)
if nargin > 3
error('Too many input arguments')
elseif nargin==1
f0=1;f1=2;
elseif nargin==2
f1=2;
end
val0=ceil(f0)-(f0);
val1=ceil(f1)-(f1);
if val0 ~=0 || val1 ~=0;
error('Frequency must be an integer');
end
if f0<1 || f1<1;
error('Frequency must be bigger than 1');
end
t=0:2*pi/99:2*pi;
cp=[];sp=[];
mod=[];mod1=[];bit=[];
for n=1:length(g);
if g(n)==0;
die=ones(1,100);
c=sin(f0*t);
se=zeros(1,100);
else g(n)==1;
die=ones(1,100);
c=sin(f1*t);
se=ones(1,100);
end
cp=[cp die];
mod=[mod c];
bit=[bit se];
end
ask=cp.*mod;
subplot(2,1,1);plot(bit,'LineWidth',1.5);grid on;
title('Binary Signal');
axis([0 100*length(g) -2.5 2.5]);
subplot(2,1,2);plot(ask,'LineWidth',1.5);grid on;
title('FSK modulation');
axis([0 100*length(g) -2.5 2.5]);

You might also like