Why my frequency domain graph looks so weird?

조회 수: 2 (최근 30일)
ong jia eek
ong jia eek 2019년 10월 1일
답변: Star Strider 2019년 10월 1일
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
Walter Roberson
Walter Roberson 2019년 10월 1일
What are the inputs you are using in response to the input() requests?

댓글을 달려면 로그인하십시오.

답변 (1개)

Star Strider
Star Strider 2019년 10월 1일
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');

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by