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

📄 demodsig.m

📁 很多matlab的源代码
💻 M
字号:
function xd =demodsig(ty,x,c,k)
%DEMODSIG Demodulates AM, FM and PM signals
%
%	xd=DEMODSIG(ty,x,c,k)  Demodulates the modulated signal in x
%	ty='am','fm' or 'pm' x=modulated signal, xm = message signal, 
%	k=beta (standard AM) or kp(rad/unit) (for PM) or kf(Hz/unit) (for FM)
%	FOR DSBSC: k is not required
%	c=[f ts] = [carrier frequency, sampling interval]  Default: ts=1
%	The modulated signal has the form
%	For DSBSC AM:    xm = x.*cos(2*pi*f*t)
%	For Standard AM: xm = (1+k*x).*cos(2*pi*f*t)
%	For PM:          xm = cos(2*pi*f*t+k*x)
%	For FM:          xm = cos(2*pi*f*t+2*pi*k*cumsum(x)*ts)
%	FOR PM and FM also returns: xp=phase   xf=instantaneous frequency
%	RESULTS ARE PLOTTED IF NO OUTPUT ARGUMENTS GIVEN
%
%	DEMODSIG (with no input arguments) invokes the following example:
%
%	Modulate and demodulate a triangular message using FM with 
%	fc=2Hz,ts=0.01, Kf=10, and compare the actual and recovered signal
%	t=0:.01:2;y=tri(t-1);modsig('fm',y,[2 0.01],10);xm=ans;
%	yd=demodsig('fm',xm,[2 0.01],10)


% ADSP Toolbox: Version 2.0 
% For use with "Analog and Digital Signal Processing", 2nd Ed.
% Published by PWS Publishing Co.
%
% Ashok Ambardar, EE Dept. MTU, Houghton, MI 49931, USA
% http://www.ee.mtu/faculty/akambard.html
% e-mail: akambard@mtu.edu
% Copyright (c) 1998


if nargin==0,help demodsig,disp('Strike a key to see results of the example')
pause,t=0:.01:2;y=tri(t-1);modsig('fm',y,[2 0.01],10);xm=ans;
xdm=demodsig('fm',xm,[2 0.01],10);plot(t,y,'g',t,xdm,'r'),grid
title('Actual (g) and recovered (r) message after demodulation'),return,end

ty1=ty(1);f=c(1);if length(c)==2,ts=c(2);else,ts=1;end
l=length(x);t=(0:l-1)*ts;j=sqrt(-1);xd=analytic(x).*exp(-j*2*pi*f*t);
if ty1=='a',
%xd=x.*cos(2*pi*f*t);[b,a]=butter(5,2*k*f*ts);xd=filtfilt(b,a,real(xd));
xd=real(xd);if nargin>3,xd=(xd-1)/k;end
elseif ty1=='p',
xd=angle(xd)/k;
elseif ty1=='f',
xd=[0 diff(unwrap(angle(xd)))]/(2*pi*k*ts);
else,error('Unidentified modulation type. Use am pm or fm'),return,end
if nargout>0,return,end
clg,plot(t,xd),title(['message signal for ' ty])

⌨️ 快捷键说明

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