|
From: | Kavya Manohar |
Subject: | Re: FM modulation of a sqarewave carrier with sinusoidal message in gnu-octave |
Date: | Fri, 30 May 2014 09:43:24 +0530 |
I'm copying the relevant section of your code here for the benefit of
others following along:
x_max=max(x);
x_modulating=x./x_max;
fdev=x_modulating*fc/2;
fc=fc*ones(size(t));
z=5.*square(2*pi*((fc+fdev).*t));
It's close but not quite frequency modulation. Check the definition
again, and remember that the argument to the sin or square function is
a phase vector. When the frequency is constant, the phase is simply
fc*t, but when you have a variable instantaneous frequency, you have
to integrate it over time. In discrete time this can be done with
cumsum(fdev)/Fs.
So what you want is probably something more like
z = square (2*pi*fc.*t + 2*pi*cumsum(fdev)/Fs);
You can also look at the fmmod function in the Octave Forge
communications package.
HTH,
--
mike
[Prev in Thread] | Current Thread | [Next in Thread] |