Kindly help with fsk demodulation

3 views (last 30 days)
Hello,
This is my code for fsk modulation and demodulation in MATLAB. I am able to do it upto modulation.However fskdemod command is throwing up an error saying that "nsamp" has to be greater than 1.This despite the fact that I am using a number greater than 1.Kindly help me.I am at my wits end :(
clc;
clear ;
close all;
% For Plots :
set(0,'DefaultAxesFontSize',20); % Default font size for plots
set(0,'DefaultLineLineWidth',2.0); % Default line width for plots
set(0,'DefaultTextInterpreter','latex'); % Default text interpreter
%-----------------------START OF PROGRAM-----------------------%
b = [1 1 0 0 1 1 0 1];
n = length(b);
t = 0:.01:n;
F=1:n;
N1=800;
SNR=30;
b_p = 2*b - 1;
bw = zeros(size(t));
N = N1/n;
for idx = 1:n
bw(N*(idx-1)+1:idx*N) = b_p(idx);
end
wo = 4*pi*t;
W = 2*pi*t;
sinHt = sin(wo+W); %--First Carrier Wave--%
sinLt = sin(wo-W); %--Second Carrier Wave--%
st = sin(wo+(bw).*W); %--Modulated Wave--%
%-----------------------PLOTTING MODULATED SIGNALS-----------------------%
figure;
plot(t,bw);
title('Given Bit Input');
xlabel('time');
ylabel('amplitude');
grid on ;
figure('Name','Carriers');
subplot(2,1,1);
plot(t,sinHt);
title('First Carrier Wave');
xlabel('time');
ylabel('amplitude');
grid on ;
subplot(2,1,2);
plot(t,sinLt);
title('Second Carrier Wave');
xlabel('time');
ylabel('amplitude');
grid on ;
figure('Name','Modulated Wave');
plot(t,st);
title('Modulated Waveform');
xlabel('time');
ylabel('amplitude');
grid on ;
%-----------------------ADDING NOISE-----------------------%
swn=awgn(st,SNR);
figure('Name','Modulated Signal with Noise');
plot(t,swn);
xlabel('time');
ylabel('amplitude');
grid on ;
%-----------------------DEMODULATION-----------------------%
fd=fskdemod(swn,2,8,1);
figure;
plot(F,fd);
grid ON;
%-----------------------------------------------------------------------------%

Answers (1)

John D'Errico
John D'Errico on 26 Nov 2016
Edited: John D'Errico on 26 Nov 2016
Hmm. I'll accept that you THINK you passed in a number greater than 1.
This is the calling sequence, copied directly from the help for fskdemod:
z = fskdemod(y,M,freq_sep,nsamp)
You should see that the 4th argument is nsamp.
Here is your call to that function:
fd=fskdemod(swn,2,8,1);
It looks like a 1 to me - that symbol that appears after the third comma in the argument list. :)
So, when I read the statement: "fskdemod command is throwing up an error saying that "nsamp" has to be greater than 1.", well I assume that you might do better if you pass in a number greater than 1. It is only a guess on my part of course.
  3 Comments
John D'Errico
John D'Errico on 27 Nov 2016
Edited: Walter Roberson on 27 Nov 2016
Lacking that toolbox, I'd read the help.
It seems to indicate that fskdemod works down the rows of y, that with multiple columns, it process each column independently. I cannot test that fact however. You are passing it a row vector, which might seem to cause problems.
Aditi Moudgalya Sreeroop
Aditi Moudgalya Sreeroop on 28 Nov 2016
Heya,
It is still not working :( I have attached the pic :(

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!