FM Signal in matlab
74 views (last 30 days)
Show older comments
ong jia eek
on 29 Sep 2019
Commented: Darel
on 17 Mar 2023
Hi guys, I wish to get help on 3 things
- How to set border for the graph?
- How to set only 2 cycle in the result?( means instead of many cycle,I want to have only 2 cycle every time when we key in user input)
- How to change from time domain to frequency domain?
%FM generation
clc;
clear all;
close all;
fc=input('Enter the carrier signal freq in hz,fc=');
fm=input('Enter the modulating signal freq in hz,fm =');
m=input('Modulation index,m= ');
t=0:0.0001:0.1;
c=cos(2*pi*fc*t);%carrier signal
M=sin(2*pi*fm*t);% modulating signal
subplot(3,1,1);plot(t,c);
ylabel('amplitude');xlabel('time index');title('Carrier signal');
subplot(3,1,2);plot(t,M);
ylabel('amplitude');xlabel('time index');title('Modulating signal');
y=cos(2*pi*fc*t-(m.*cos(2*pi*fm*t)));
subplot(3,1,3);plot(t,y);
ylabel('amplitude');xlabel('time index');title('Frequency Modulated signal');
fs=10000;
p=fmdemod(y,fc,fs,(fc-fm));
figure;
subplot(1,1,1);plot(p);
3 Comments
Accepted Answer
Samyuktha Premkumar
on 8 Jan 2023
%FM generation
clc;
clear all;
close all;
fc=input('Enter the carrier signal freq in hz,fc=');
fm=input('Enter the modulating signal freq in hz,fm =');
m=input('Modulation index,m= ');
t=0:0.0001:0.1;
c=cos(2*pi*fc*t);%carrier signal
M=sin(2*pi*fm*t);% modulating signal
subplot(3,1,1);plot(t,c);
ylabel('amplitude');xlabel('time index');title('Carrier signal');
subplot(3,1,2);plot(t,M);
ylabel('amplitude');xlabel('time index');title('Modulating signal');
y=cos(2*pi*fc*t-(m.*cos(2*pi*fm*t)));
subplot(3,1,3);plot(t,y);
ylabel('amplitude');xlabel('time index');title('Frequency Modulated signal');
fs=10000;
p=fmdemod(y,fc,fs,(fc-fm));
figure;
subplot(1,1,1);plot(p);
1 Comment
More Answers (6)
ong jia eek
on 29 Sep 2019
3 Comments
Walter Roberson
on 30 Sep 2019
aliasing. Your modulated signal needs a higher sampling frequency than the base frequency if you want to see non-clipped waveforms.
Mohammad Yar
on 15 Jan 2021
%Modulated Signal:
z = ammod(x, fc, fs, 0, Ac);
figure(5);
plot(t(1:1000), z(1:1000));
title('Modulated Signal');
xlabel('time(t)');
ylabel('Amplitude');
%Z=(fft(z));
lfftmz=length(z);
ffmz=fftshift(fft(z));
mfftz=(-lfftmz/2:lfftmz/2-1)/(lfftmz*T);
figure(6);
plot(mfftz,abs(ffmz));
title('frequency domain AM');
*(any one please explaine this code)
0 Comments
Mohammad Yar
on 15 Jan 2021
Edited: Walter Roberson
on 8 Jan 2023
clc;
close all;
clear all;
h=0.5; fs=1000;
T=1/fs; t=0:T:1;
%Message Signal:
Am = 10;
fm = 10;
x = Am*sin(2*pi*fm*t);
figure;
figure(1);
plot(t, x);
lfftm=length(x);
ffm=fftshift(fft(x));
mfft=(-lfftm/2:lfftm/2-1)/(lfftm*T);
title('Message Signal');
xlabel('time(t)');
ylabel('Amplitude');
%X=fft(x);
figure(2);
plot(mfft,abs(ffm));
title('frequency domain msg');
*(any one please explaine this code)
.
0 Comments
Mohammad Yar
on 15 Jan 2021
%Demodulated Signal:
d = amdemod(z, fc, fs, 0, Ac);
figure(7);
plot(t(1:1000), d(1:1000));
title('Demodulated Signal');
xlabel('time(t)');
ylabel('Amplitude');
ylim([-10, 10]);
%D=fft(d);
lfftmd=length(x);
ffmd=fftshift(fft(x));
mfftd=(-lfftmd/2:lfftmd/2-1)/(lfftmd*T);
figure(8);
plot(mfftd,abs(ffmd));
title('frequency domain demodulation');
*(any one please explaine this code)
0 Comments
Mohammad Yar
on 15 Jan 2021
%Carrier Signal:
Ac = Am/h; fc = 10*fm;
y = Ac*cos(2*pi*fc*t);
figure(3);
plot(t(1:1000), y(1:1000));
title('Carrier Signal');
xlabel('time(t)');
ylabel('Amplitude');
lfftmy=length(y);
ffmy=fftshift(fft(y));
mffty=(-lfftmy/2:lfftmy/2-1)/(lfftmy*T);
%Y=fft(y); figure(4);
plot(mffty,abs(ffmy));
title('frequency domain carrier');
*(any one please explaine this code)
0 Comments
Mayur Ingle
on 20 May 2022
clear all;
close all;
fm=input('Enter the modulating signal:');
fc=input('Enter the carrier signal:');
Em=input('Enter the modulating voltage:');
Ec=input('Enter the carrier voltage:');
m=input('Enter the value of modulation index:');
t=0:0.01:10;
A=cos(6.28*fm*t); %mathematical equation of modulating signal
B=cos(6.28*fc*t); %mathematical equation of Carrier signal
C=Ec*cos(6.28*fc*t + m*sin(6.28*fm*t)); %mathematical equation of FM signal
subplot(3,1,1);
plot(t,A);
xlabel('time');
ylabel('Amplitude');
title('Modulating Signal');
subplot(3,1,2);
plot(t,B);
xlabel('time');
ylabel('Amplitude');
title('Carrier Signal');
subplot(3,1,3);
plot(t,C);
xlabel('time');
ylabel('Amplitude');
title('Modulated Signal');
0 Comments
See Also
Categories
Find more on Modulation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!