0
$\begingroup$

While searching for something FM, I came across this code. I am not able to understand a particular line of code. I have written a comment against that line of code.

fs = 1000;
fc = 200;
t = (0:1/fs:0.2)';
x = sin(2*pi*30*t)+2*sin(2*pi*60*t);
fDev = 50;
int_x = cumsum(x)/fs;  %%% This line of code
xfm = cos(2*pi*fc*t).*cos(2*pi*fDev*int_x)-sin(2*pi*fc*t).*sin(2*pi*fDev*int_x)   ;

I understand the cumsum function but I am not able to understand why is he dividing the integration by Fs i.e. sampling frequency.

Link to the code - https://in.mathworks.com/matlabcentral/answers/318969-fm-modulation-without-using-fmmod

$\endgroup$
3
$\begingroup$

When generating the sine wave, the code uses a sampling frequency to establish discrete points in the time domain. It is not continuous. This means the wave is broken up into bins that are exactly 1/fs in size/width.

So if you want a true integral of the wave, you have to take the average density of all the points in a bin by dividing by the sampling frequency.

Hope that helped.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.