How to code a spectrum frequency that allow me do scaling frequency?

조회 수: 1 (최근 30일)
ong jia eek
ong jia eek 2019년 10월 1일
편집: ong jia eek 2019년 10월 1일
This is the code for FM in matlab
I used fft to produce frequency domain graph but my lecturer wanted a frequency spectrum .
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= ');
tm=(1/fm)*2;
t=0:1/(fc*1000):tm;
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;
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');

답변 (0개)

카테고리

Help CenterFile Exchange에서 Propagation and Channel Models에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by