matlab dmod函数
时间: 2024-06-10 12:03:01 浏览: 16
dmod函数在MATLAB中可以用于产生数字调制信号。该函数可以对输入信号进行频移调制,包括ASK、PSK、FSK等多种调制方式。该函数的语法如下:
```matlab
y = dmod(x,Fc,Fs,modtype,varargin)
```
其中,x为输入信号,Fc为载频频率,Fs为采样频率,modtype为调制方式,varargin为可选参数。下面是一个例子,将一段数字信号进行2FSK调制:
```matlab
Fs = 10000;
Fc1 = 1000;
Fc2 = 2000;
M = 2;
x = [0, 1, 0, 1, 1, 0, 0, 1];
y = dmod(x, Fc1, Fs, 'fsk', M, Fc2 - Fc1);
```
其中,载频频率Fc1为1000Hz,Fs为采样频率为10000Hz,调制方式为2FSK,M为调制阶数为2,两个频率之间的频率偏移量为Fc2 - Fc1。该函数的输出y为数字调制后的信号。
相关问题
matlab中dmod函数
在MATLAB中,dmod函数是用于进行数字调制的函数。该函数的语法如下:
y = dmod(x,M)
其中,x是要进行数字调制的信号序列,M是调制方案(即调制方式和调制阶数)。
调制方案可以是'psk'、'fsk'、'ask'、'qam'、'ofdm'中的一种,对应的调制方式和调制阶数分别为:
- 'psk':相位调制,其中M为调制阶数,可以是2、4、8等。
- 'fsk':频率调制,其中M为调制阶数,可以是2、4、8等。
- 'ask':幅度调制,其中M为调制阶数,可以是2、4、8等。
- 'qam':正交振幅调制,其中M为调制阶数,可以是16、64、256等。
- 'ofdm':正交频分复用调制。
dmod函数的返回值y为进行数字调制后的信号序列。
matlab 的wavedec函数源程序
`wavedec` 函数是 Matlab 中用于进行小波分解的函数之一,以下是它的源程序:
```matlab
function [C,L] = wavedec(X,N,Lo_D,Hi_D)
%WAVEDEC Multilevel 1-D wavelet decomposition.
% WAVEDEC performs a multilevel 1-D wavelet decomposition
% of the signal X at level N, using the wavelet filters
% Lo_D and Hi_D (called the decomposition filters or the
% analysis filters) obtained from the wavelet wname.
%
% C = WAVEDEC(X,N,'wname') returns the wavelet decomposition
% of the signal X at level N, using 'wname'. 'wname' is a string
% containing the name of the wavelet (see WFILTERS).
% C is a vector containing the detailed coefficients (called
% the wavelet coefficients or the detail coefficients) of the
% decomposition. Length(C) = length(X) so that the approximation
% coefficients (see WAPPDEC) can be obtained using the command
% APPCOEF(C,L,'wname',N).
%
% [C,L] = WAVEDEC(...) returns the vector of wavelet
% coefficients C and the bookkeeping matrix L which contains
% the lengths of the successive subbands and the position of
% the first coefficient of each subband in C. Such a bookkeeping
% matrix is useful when you want to manipulate wavelet
% coefficients.
%
% C = WAVEDEC(X,N,Lo_D,Hi_D) returns the wavelet decomposition
% of the signal X at level N, using Lo_D and Hi_D. Lo_D and Hi_D
% are the decomposition filters.
%
% See also APPCOEF, DETCOEF, WRcoef, UPWLEV, WAVEREC.
% M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 01-Jun-95.
% Last Revision: 15-Sep-99.
% Check arguments for Extension and Shift.
%---------------------------------------------------------%
nbIn = nargin;
shift = 0;
if ischar(N)
[Lo_D,Hi_D] = wfilters(N,'d');
N = varargin{1};
nbIn = nbIn-1;
elseif ischar(Lo_D)
[Lo_D,Hi_D] = wfilters(Lo_D,'d');
shift = nargin-2;
nbIn = nbIn-2;
end
if nbIn<2 , error(message('Wavelet:wavelet:Invalid_ArgNum')); end
if ~isnumeric(N) || N<0 || fix(N)~=N
error(message('Wavelet:wavelet:Invalid_WavLevel'));
end
% Initialization.
%---------------------------------------------------------%
if rem(size(Lo_D,2),2) , Lo_D = Lo_D(:)' ; end
if rem(size(Hi_D,2),2) , Hi_D = Hi_D(:)' ; end
X = X(:)';
cA = X;
sizes = zeros(N+1,length(cA));
sizes(N+1,:) = length(cA);
Lo_D = Lo_D(:)';
Hi_D = Hi_D(:)';
for k = 1:N
[cA,cD] = dwtImpl(cA,Lo_D,Hi_D);
sizes(N+1-k,:) = length(cA);
end
C = [cA , cD];
L = diff([0 sizes(:)'-shift]);
%---------------------------------------------------------%
function [app,detail] = dwtImpl(signal,F1,F2)
% Compute sizes.
lf = length(F1);
lx = length(signal);
lx = lx + rem(lf-mod(lx,lf),lf);
ly = lx/lf;
signal(lx) = 0;
% Compute coefficients of low-pass and high-pass filters.
F1 = F1(:)';
F2 = F2(:)';
F1 = F1(:,ones(1,ly));
F2 = F2(:,ones(1,ly));
signal = signal(:);
signal = signal(ones(1,ly),:);
% Filtering.
app = sum(signal .* F1, 1);
detail = sum(signal .* F2, 1);
% Upsampling.
app = app(:)';
detail = detail(:)';
```
该函数的输入参数包括:信号 X、小波分解级数 N、小波分解滤波器的低通滤波器 Lo_D 和高通滤波器 Hi_D。输出参数包括:小波分解系数 C 和分解结构 L。
在 `wavedec` 函数中,首先会对输入参数进行检查和初始化,然后根据小波分解级数 N 和滤波器 Lo_D 和 Hi_D 对信号进行小波分解,得到小波分解系数 C 和分解结构 L。最后将 C 和 L 输出。