Effacer les filtres
Effacer les filtres

Why my frequency domain graph looks so weird?

3 vues (au cours des 30 derniers jours)
ong jia eek
ong jia eek le 1 Oct 2019
This is the result of my frequency modulated signal in frequency domain, may I ask whether how can I avoid the big gap between each cycle
below is my coding
%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=1000;% this will define the the resolution.
z=fft(y);
nfft = length(y);
f = (0:1/nfft:1-1/nfft)*fs; % define frequency-domain
figure; % figure should be written before subplot to open new figure
subplot(2,1,1); % subplot(2,1,4) will give error beacause for a 2x1 vector valid indeces are 1&2, 4 is wrong
plot(f,z); % t (time-domain) is replace with f (frequency-domain)
ylabel('amplitude');xlabel('frequency domain');title('Frequency Modulated signal');
  1 commentaire
Walter Roberson
Walter Roberson le 1 Oct 2019
What are the inputs you are using in response to the input() requests?

Connectez-vous pour commenter.

Réponses (1)

Star Strider
Star Strider le 1 Oct 2019
You are plotting only the real part of a two-sided Fourier transform.
Try this:
fs=1000;% this will define the the resolution.
fn = fs/2; % Nyquist Frequency
z=fft(y)/numel(y);
nfft = fix(length(y)/2);
f = (0:1/nfft:1-1/nfft)*fn; % define frequency-domain
figure; % figure should be written before subplot to open new figure
subplot(2,1,1); % subplot(2,1,4) will give error beacause for a 2x1 vector valid indeces are 1&2, 4 is wrong
plot(f,abs(z(1:nfft))); % t (time-domain) is replace with f (frequency-domain)
ylabel('amplitude');xlabel('frequency domain');title('Frequency Modulated signal');

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by