Why my frequency domain graph looks so weird?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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');
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spectral Measurements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!