FM Signal in matlab

74 次查看(过去 30 天)
ong jia eek
ong jia eek 2019-9-29
评论: Darel 2023-3-17
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 个评论
Prasanna S K
Prasanna S K 2020-11-29
Use of subplot
Walter Roberson
Walter Roberson 2020-11-29
Please expand on what you mean by "Use of subplot" ?

请先登录,再进行评论。

采纳的回答

Samyuktha Premkumar
%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 个评论
Darel
Darel 2023-3-17
As above, but change
t=0:0.0001:0.1;
to
t=0:0.0001:2/fm;

请先登录,再进行评论。

更多回答(6 个)

ong jia eek
ong jia eek 2019-9-29
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 个评论
ong jia eek
ong jia eek 2019-9-30
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 2019-9-30
aliasing. Your modulated signal needs a higher sampling frequency than the base frequency if you want to see non-clipped waveforms.

请先登录,再进行评论。


Mohammad Yar
Mohammad Yar 2021-1-15
%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 2021-1-15
编辑:Walter Roberson 2023-1-8
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 2021-1-15
%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 2021-1-15
%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 2022-5-20
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');

类别

Help CenterFile Exchange 中查找有关 Modulation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by