⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fmdemod_4.m

📁 matlab编程实现FM信号的解调程序
💻 M
字号:
% This is a demodulation program with different FM demodulation algorithms% fmdemod_4.m% to check FM MODULATION with different methodsFs = 102000; % Sampling rate of signalFc = 25000; % Carrier frequencyAXIS_NUM = 10000;t = [0:AXIS_NUM]'/Fs; % Sampling timess1 = sin(2*pi*100*t);%+2*sin(2*pi*600*t); % Channel 1s2 = sin(2*pi*150*t)+2*sin(2*pi*900*t); % Channel 2x = s1;%[s1,s2]; % Two-channel signaldev = 3; % Frequency deviation in modulated signal%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%        % Frequency Modulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%        % applying function fmmod() and fmdemod()y = fmmod(x,Fc,Fs,dev); % Modulate both channels.z = fmdemod(y,Fc,Fs,dev); % Demodulate both channels        % applying analystical expressions and fmdemod()y2 = 10*cos(2*pi*Fc*t + 2*pi*cumsum(x)*dev/Fs);z2 = fmdemod(y2,Fc,Fs,dev); % Demodulate both channelsfigure(1),clf;                              %plot demodulation signalsplot([y,y2]),title('FM modulation using different methods');% plot([z z2]),title('FM demodulated using different way');legend('function fmmod()','analytical expression');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                            % FM demodulation%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                            % method 1 : fmdemod() solution%z = fmdemod(y2,Fc,Fs,dev);                            % method 2 % orthorgnal demoduation                            % 2.1 multiplyingini_phase = 15;ri = y2.*cos(2*pi*Fc*t+ini_phase);rq = -y2.*sin(2*pi*Fc*t+ini_phase);                            % 2.2 Filtering      b = fir1(100,0.1);                            rif = filter(b,1,ri);rqf = filter(b,1,rq);                            % 2.3 Calculate instance phase and frequncy                            % Applying arctangent methodsinstance_phase = atan2(rqf,rif);instance_freq  = (diff(detrend(unwrap(instance_phase))));amp_adjust = std(s1)/std(instance_freq(100:end));                            % 2.4 Applying I-Q difference calculationsrid = diff(rif);rqd = diff(rqf);diff_iq = (rqf(1:end-1).*rid-rif(1:end-1).*rqd)./(rif(1:end-1).^2+rqf(1:end-1).^2);% diff_iq = (rqf(1:end-1).*rid-rif(1:end-1).*rqd);figure(2),clf,hold on;plot(x(200:end-200),'k*');plot(amp_adjust*instance_freq(100:end),'r');plot(amp_adjust*diff_iq(100:end),'g')legend('original signal','demodulated by arctangent','demodulated by I-Q difference');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                        %     demodulated signal filtering%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%b = fir1(100,0.1);demod_f1 = filter(b,1,amp_adjust*instance_freq);demod_f2 = filter(b,1,amp_adjust*diff_iq);figure(3),clf,hold on;plot([demod_f1(200:end),demod_f2(200:end)]);title('filtering the demodulated signal');legend('demodulated by arctangent','demodulated by I-Q difference');% downsampling()down_f1 = downsample(demod_f1,4);down_f2 = downsample(demod_f2,4);figure(4);plot([down_f1,down_f2]);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                        %     The End%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -