
FREQUENCY MODULATION (FM) WITH MATLAB CODE
BASIC
Frequency Modulation (AM) is a one of the conventional modulation technique to transmit signals using a carrier wave. The frequency of a high frequency carrier wave is changed in accordance with the frequency of message signal. In frequency modulation amplitude of the carrier signal remain same.
In amplitude Modulation or Frequency Modulation frequency of message signal is always smaller than the frequency of carrier signal.
If,
- Ac = Amplitude of the carrier signal
- Am = Amplitude of the message signal
- fc = frequency of the carrier signal
- fm = frequency of the message signal
- Yc = Carrier signal
- Ym = Message signal
Then,
Yc = Acsin(2πfct)
Ym = Amsin(2πfmt)
The modulated signal will be,
Z = Acsin(2πfct+((Am/Ac)(2π fmt)))
or,
Z = Acsin(2πfct+(m(2π fmt)))
Where modulation index m= Am/Ac
MATLAB CODE
We need to know amplitude and frequency of carrier signal and message signal. So we will ask to user for Frequency and Amplitude of carrier signal and message signal.
Ac = input('Carrier Signal Amplitude: '); Am = input('Message Signal Amplitude: '); fc = input('Carrier Signal Frequency: '); fm = input('Message Signal Frequency: ');
Frequency of message signal cannot be greater than frequency of carrier signal. So, if user entered a frequency of message signal that is greater than the carrier signal then we will show that invalid. How long the frequency of message signal is not less than the frequency of carrier signal we will reject that and ask for the frequency again.
while fm>fc disp('Message Signal Frequency is Incorrect.'); fm = input('Message Signal Frequency: '); end
We need a fixed time period for those signals. We will take it from the user.
T = input('Time Period: ');
We need to find the time domain values. We will find it from the fraction below.
t = 0:0.001:T;
Now, derive the message signal as below.
Ym = Am.*sin(2*pi*fm*t);
Make a subpolt as 3 by 1 size. Place the message signal (upcoming) to first subplot. Set the title.
subplot(3, 1, 1); plot(t, Ym); title('Message Signal');
Now, derive the carrier signal as below.
Yc = Ac.*sin(2*pi*fc*t);
Place the carrier signal (upcoming) to second subplot. Set the title.
subplot(3, 1, 2); plot(t, Yc); title('Carrier Signal');
Now, Derive the modulated signal.
Z = Ac.*sin(2*pi*fc*t+((Am/Ac).*(2*pi*fm*t)));
Place the modulated signal (upcoming) to third subplot. Set the title.
subplot(3, 1, 3); plot(t, Z, 'r'); title('Modulated Signal');
FULL CODE
Ac = input('Carrier Signal Amplitude: '); Am = input('Message Signal Amplitude: '); fc = input('Carrier Signal Frequency: '); fm = input('Message Signal Frequency: '); while fm>fc disp('Message Signal Frequency is Incorrect.'); fm = input('Message Signal Frequency: '); end T = input('Time Period: '); t = 0:0.001:T; Ym = Am.*sin(2*pi*fm*t); subplot(3, 1, 1); plot(t, Ym); title('Message Signal'); Yc = Ac.*sin(2*pi*fc*t); subplot(3, 1, 2); plot(t, Yc); title('Carrier Signal'); Z = Ac.*sin(2*pi*fc*t+((Am/Ac).*(2*pi*fm*t))); subplot(3, 1, 3); plot(t, Z, 'r'); title('Modulated Signal');
OUTPUT
Output of the code above with Am=1, Ac=1, fc=5, fm=4, T=4.

I think your experience with this tutorial is quite good. If you have to seek anything please comment or report by form.
Thanks.