简体   繁体   中英

Frequency modulation function in Matlab

I'm attempting this matlab code but I keep getting an error. Any hints?

%Frequency Demodulation
f_fmCarrier=1000; %frequency of FM carrier signal
f_sampling=f_fmCarrier*2; %frequency of sampling
recordFmModulatedSignal=audiorecorder(f_sampling,16,1,1);
recordblocking(recordFmModulatedSignal,5);
rFmModulatedSignal=getaudiodata(recordFmModulatedSignal);
figure(2)
subplot(3,1,1);
plot(rFmModulatedSignal,'b');
title('Recieved FM Modulated signal');
xlabel('Seconds');
ylabel('Amplitude');
fmMessageSignal=fmdemod(rFmModulatedSignal,f_fmCarrier,f_sampling,mod_index*f_fmMessageSignal);
subplot(3,1,2);
plot(fmMessageSignal,'r');
title('Demodulated signal by using fmdemod command');
xlabel('Seconds');
ylabel('Amplitude');
B_fm=fir1(401,2*(f_fmMessageSignal/f_sampling));% lowpass filter of order 401 & frequency
fmMessageSignal2=filter(B_fm,1,fmMessageSignal);
subplot(3,1,3);
plot(fmMessageSignal2,'m');
title('Demodulated signal by using a lowpass filter');
xlabel('Seconds');
ylabel('Amplitude');

error:

Undefined function 'fmdemod' for input arguments of type 'double'.

Error in project2 (line 32)
fmMessageSignal=fmdemod(rFmModulatedSignal,f_fmCarrier,f_sampling,mod_index*f_fmMessageSignal);

fmdemod is not a built-in function in MATLAB, hence the error. Specifically, it is located in the Communications System Toolbox, which it appears you don't have.

You'll need to write your own or find an implementation that conforms to the interface that your above snippet requires. Here is online documentation for the version in the toolbox .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM