FM Signal in matlab

139 vues (au cours des 30 derniers jours)
ong jia eek
ong jia eek le 29 Sep 2019
Commenté : Darel le 17 Mar 2023
Hi guys, I wish to get help on 3 things
  1. How to set border for the graph?
  2. 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)
  3. 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 commentaires
Prasanna S K
Prasanna S K le 29 Nov 2020
Use of subplot
Walter Roberson
Walter Roberson le 29 Nov 2020
Please expand on what you mean by "Use of subplot" ?

Connectez-vous pour commenter.

Réponse acceptée

Samyuktha Premkumar
Samyuktha Premkumar le 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 commentaire
Darel
Darel le 17 Mar 2023
As above, but change
t=0:0.0001:0.1;
to
t=0:0.0001:2/fm;

Connectez-vous pour commenter.

Plus de réponses (6)

ong jia eek
ong jia eek le 29 Sep 2019
Figure 1
carrier signal freq in hz,fc=1000
modulating signal freq in hz,fm =100
Modulation index,m= 8
WhatsApp Image 2019-09-29 at 3.13.50 PM.jpeg
Figure 2
he carrier signal freq in hz,fc=100
the modulating signal freq in hz,fm =10
Modulation index,m= 8
WhatsApp Image 2019-09-29 at 3.12.37 PM.jpeg
I wish to get 2 cycle of modulating signal in any value of carrier signal freq and modulating signal freq. As in figure 1, it shows too much cycle in one diagram, I just wish to get 2 cycle only in any cases of carrier signal freq and modulating signal freq
  3 commentaires
ong jia eek
ong jia eek le 30 Sep 2019
thanks.
I wish to ask about why is this happened when
the carrier signal freq in hz,fc=10000
the modulating signal freq in hz,fm =1000
Modulation index,m= 8
Below is my newly edited matlab code.
%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=(1/fc)*20;
t=0:0.0001:t;
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=2*fc;
p=fmdemod(y,fc,fs,(fc-fm));
figure;
subplot(1,1,1);plot(p);
Where did I did wrongly in the code that cause this to happened.
Walter Roberson
Walter Roberson le 30 Sep 2019
aliasing. Your modulated signal needs a higher sampling frequency than the base frequency if you want to see non-clipped waveforms.

Connectez-vous pour commenter.


Mohammad Yar
Mohammad Yar le 15 Jan 2021
Modifié(e) : Walter Roberson le 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)
.

Mohammad Yar
Mohammad Yar le 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)

Mohammad Yar
Mohammad Yar le 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)

Mohammad Yar
Mohammad Yar le 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)

Mayur Ingle
Mayur Ingle le 20 Mai 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');

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by