Matlab错误:未定义函数';dmod';对于类型为';双倍';。为什么没有dmod函数,因为它应该与Matlab一起提供?
我一直在做一些考试,需要做一个涉及一些频移键控的练习。这就是为什么我使用Matlab中的dmod函数——它是Matlab自带的。但当我在控制台上写下Matlab错误:未定义函数';dmod';对于类型为';双倍';。为什么没有dmod函数,因为它应该与Matlab一起提供?,matlab,Matlab,我一直在做一些考试,需要做一个涉及一些频移键控的练习。这就是为什么我使用Matlab中的dmod函数——它是Matlab自带的。但当我在控制台上写下 yfsk=dmod([10],3,0.5100,'fsk',2,1) 它给了我这个 “double”类型输入参数的未定义函数“dmod”。 我还尝试了doc dmod,它在matlab帮助窗口中显示“未找到页面” 你知道这是因为我没有安装所有的matlab软件包,还是Matlab2012a不支持这个函数? 谢谢我想您可能正在从信号处理工具箱中寻找解
yfsk=dmod([10],3,0.5100,'fsk',2,1)代码>
它给了我这个
“double”类型输入参数的未定义函数“dmod”。
我还尝试了doc dmod
,它在matlab帮助窗口中显示“未找到页面”
你知道这是因为我没有安装所有的matlab软件包,还是Matlab2012a不支持这个函数?
谢谢我想您可能正在从信号处理工具箱中寻找解调功能(解调)
这会很有帮助:
function [y, t] = dmod(x, Fc, Fd, Fs, method, M, opt2, opt3)
%DMOD
%
%WARNING: This is an obsolete function and may be removed in the future.
% Please use MODEM.PAMMOD, MODEM.QAMMOD, MODEM.GENQAMMOD, FSKMOD,
% MODEM.PSKMOD, or MODEM.MSKMOD instead.
% Y = DMOD(X, Fc, Fd, Fs, METHOD...) modulates the message signal X
% with carrier frequency Fc (Hz) and symbol frequency Fd (Hz). The
% sample frequency of Y is Fs (Hz), where Fs > Fc and where Fs/Fd is
% a positive integer. For information about METHOD and subsequent
% parameters, and about using a specific modulation technique,
% type one of these commands at the MATLAB prompt:
%
% FOR DETAILS, TYPE MODULATION TECHNIQUE
% dmod ask % M-ary amplitude shift keying modulation
% dmod psk % M-ary phase shift keying modulation
% dmod qask % M-ary quadrature amplitude shift keying
% % modulation
% dmod fsk % M-ary frequency shift keying modulation
% dmod msk % Minimum shift keying modulation
%
% For baseband simulation, use DMODCE. To plot signal constellations,
% use MODMAP.
%
% See also DDEMOD, DMODCE, DDEMODCE, MODMAP, AMOD, ADEMOD.
% Copyright 1996-2007 The MathWorks, Inc.
% $Revision: 1.1.6.5 $ $Date: 2007/06/08 15:53:47 $
warnobsolete(mfilename, 'Please use MODEM.PAMMOD, MODEM.QAMMOD, MODEM.GENQAMMOD, FSKMOD, MODEM.PSKMOD, or MODEM.MSKMOD instead.');
swqaskenco = warning('off', 'comm:obsolete:qaskenco');
swapkconst = warning('off', 'comm:obsolete:apkconst');
swmodmap = warning('off', 'comm:obsolete:modmap');
swamod = warning('off', 'comm:obsolete:amod');
opt_pos = 6; % position of 1st optional parameter
if nargout > 0
y = []; t = [];
end
if nargin < 1
feval('help','dmod')
return;
elseif isstr(x)
method = lower(deblank(x));
if length(method) < 3
error('Invalid method option for DMOD.')
end
if nargin == 1
% help lines for individual modulation method.
addition = 'See also DDEMOD, DMODCE, DDEMODCE, MODMAP, AMOD, ADEMOD.';
if method(1:3) == 'qas'
callhelp('dmod.hlp', method(1:4), addition);
else
callhelp('dmod.hlp', method(1:3), addition);
end
else
% plot constellation, make a shift.
opt_pos = opt_pos - 3;
M = Fc;
if nargin >= opt_pos
opt2 = Fd;
else
modmap(method, M);
return;
end
if nargin >= opt_pos+1
opt3 = Fs;
else
modmap(method, M, opt2);
return;
end
modmap(method, M, opt2, opt3); % plot constellation
end
return;
end
if (nargin < 4)
error('Usage: Y = DMOD(X, Fc, Fd, Fs, METHOD, OPT1, OPT2, OPT3) for passband modulation');
elseif nargin < opt_pos-1
method = 'samp';
else
method = lower(method);
end
len_x = length(x);
if length(Fs) > 1
ini_phase = Fs(2);
Fs = Fs(1);
else
ini_phase = 0; % default initial phase
end
if ~isfinite(Fs) | ~isreal(Fs) | Fs<=0
error('Fs must be a positive number.');
elseif length(Fd)~=1 | ~isfinite(Fd) | ~isreal(Fd) | Fd<=0
error('Fd must be a positive number.');
else
FsDFd = Fs/Fd; % oversampling rate
if ceil(FsDFd) ~= FsDFd
error('Fs/Fd must be a positive integer.');
end
end
if length(Fc) ~= 1 | ~isfinite(Fc) | ~isreal(Fc) | Fc <= 0
error('Fc must be a positive number. For baseband modulation, use DMODCE.');
elseif Fs/Fc < 2
warning('Fs/Fc must be much larger than 2 for accurate simulation.');
end
% determine M
if isempty(findstr(method, '/arb')) & isempty(findstr(method, '/cir'))
if nargin < opt_pos
M = max(max(x)) + 1;
M = 2^(ceil(log(M)/log(2)));
M = max(2, M);
elseif length(M) ~= 1 | ~isfinite(M) | ~isreal(M) | M <= 0 | ceil(M) ~= M
error('Alphabet size M must be a positive integer.');
end
end
if isempty(x)
y = [];
return;
end
[r, c] = size(x);
if r == 1
x = x(:);
len_x = c;
else
len_x = r;
end
% expand x from Fd to Fs.
if isempty(findstr(method, '/nomap'))
if ~isreal(x) | all(ceil(x)~=x)
error('Elements of input X must be integers in [0, M-1].');
end
yy = [];
for i = 1 : size(x, 2)
tmp = x(:, ones(1, FsDFd)*i)';
yy = [yy tmp(:)];
end
x = yy;
clear yy tmp;
end
if strncmpi(method, 'ask', 3)
if isempty(findstr(method, '/nomap'))
% --- Check that the data does not exceed the limits defined by M
if (min(min(x)) < 0) | (max(max(x)) > (M-1))
error('An element in input X is outside the permitted range.');
end
y = (x - (M - 1) / 2 ) * 2 / (M - 1);
else
y = x;
end
[y, t] = amod(y, Fc, [Fs, ini_phase], 'amdsb-sc');
elseif strncmpi(method, 'fsk', 3)
if nargin < opt_pos + 1
Tone = Fd;
else
Tone = opt2;
end
if (min(min(x)) < 0) | (max(max(x)) > (M-1))
error('An element in input X is outside the permitted range.');
end
[len_y, wid_y] = size(x);
t = (0:1/Fs:((len_y-1)/Fs))'; % column vector with all the time samples
t = t(:, ones(1, wid_y)); % replicate time vector for multi-channel operation
osc_freqs = pi*[-(M-1):2:(M-1)]*Tone;
osc_output = (0:1/Fs:((len_y-1)/Fs))'*osc_freqs;
mod_phase = zeros(size(x))+ini_phase;
for index = 1:M
mod_phase = mod_phase + (osc_output(:,index)*ones(1,wid_y)).*(x==index-1);
end
y = cos(2*pi*Fc*t+mod_phase);
elseif strncmpi(method, 'psk', 3)
% PSK is a special case of QASK.
[len_y, wid_y] = size(x);
t = (0:1/Fs:((len_y-1)/Fs))';
if findstr(method, '/nomap')
y = dmod(x, Fc, Fs, [Fs, ini_phase], 'qask/cir/nomap', M);
else
y = dmod(x, Fc, Fs, [Fs, ini_phase], 'qask/cir', M);
end
elseif strncmpi(method, 'msk', 3)
M = 2;
Tone = Fd/2;
if isempty(findstr(method, '/nomap'))
% Check that the data is binary
if (min(min(x)) < 0) | (max(max(x)) > (1))
error('An element in input X is outside the permitted range.');
end
x = (x-1/2) * Tone;
end
[len_y, wid_y] = size(x);
t = (0:1/Fs:((len_y-1)/Fs))'; % column vector with all the time samples
t = t(:, ones(1, wid_y)); % replicate time vector for multi-channel operation
x = 2 * pi * x / Fs; % scale the input frequency vector by the sampling frequency to find the incremental phase
x = [0; x(1:end-1)];
y = cos(2*pi*Fc*t+cumsum(x)+ini_phase);
elseif (strncmpi(method, 'qask', 4) | strncmpi(method, 'qam', 3) |...
strncmpi(method, 'qsk', 3) )
if findstr(method,'nomap')
[y, t] = amod(x, Fc, [Fs, ini_phase], 'qam');
else
if findstr(method, '/ar') % arbitrary constellation
if nargin < opt_pos + 1
error('Incorrect format for METHOD=''qask/arbitrary''.');
end
I = M;
Q = opt2;
M = length(I);
% leave to the end for processing
CMPLEX = I + j*Q;
elseif findstr(method, '/ci') % circular constellation
if nargin < opt_pos
error('Incorrect format for METHOD=''qask/circle''.');
end
NIC = M;
M = length(NIC);
if nargin < opt_pos+1
AIC = [1 : M];
else
AIC = opt2;
end
if nargin < opt_pos + 2
PIC = NIC * 0;
else
PIC = opt3;
end
CMPLEX = apkconst(NIC, AIC, PIC);
M = sum(NIC);
else % square constellation
[I, Q] = qaskenco(M);
CMPLEX = I + j * Q;
end
y = [];
x = x + 1;
% --- Check that the data does not exceed the limits defined by M
if (min(min(x)) < 1) | (max(max(x)) > M)
error('An element in input X is outside the permitted range.');
end
for i = 1 : size(x, 2)
tmp = CMPLEX(x(:, i));
y = [y tmp(:)];
end
ind_y = [1: size(y, 2)]';
ind_y = [ind_y, ind_y+size(y, 2)]';
ind_y = ind_y(:);
y = [real(y) imag(y)];
y = y(:, ind_y);
[y, t] = amod(y, Fc, [Fs, ini_phase], 'qam');
end
elseif strncmpi(method, 'samp', 4)
% This is for converting an input signal from sampling frequency Fd
% to sampling frequency Fs.
[len_y, wid_y] = size(x);
t = (0:1/Fs:((len_y-1)/Fs))';
y = x;
else % invalid method
error(sprintf(['You have used an invalid method.\n',...
'The method should be one of the following strings:\n',...
'\t''ask'' Amplitude shift keying modulation;\n',...
'\t''psk'' Phase shift keying modulation;\n',...
'\t''qask'' Quadrature amplitude shift-keying modulation, square constellation;\n',...
'\t''qask/cir'' Quadrature amplitude shift-keying modulation, circle constellation;\n',...
'\t''qask/arb'' Quadrature amplitude shift-keying modulation, user defined constellation;\n',...
'\t''fsk'' Frequency shift keying modulation;\n',...
'\t''msk'' Minimum shift keying modulation.']));
end
if r==1 & ~isempty(y)
y = y.';
end
warning(swqaskenco);
warning(swapkconst);
warning(swmodmap);
warning(swamod);
% [EOF]
函数[y,t]=dmod(x,Fc,Fd,Fs,method,M,opt2,opt3)
%DMOD
%
%警告:这是一个过时的功能,将来可能会被删除。
%请使用MODEM.PAMMOD、MODEM.qamod、MODEM.genqamod、FSKMOD、,
%改为MODEM.PSKMOD或MODEM.MSKMOD。
%Y=DMOD(X、Fc、Fd、Fs、方法…)调制消息信号X
%具有载波频率Fc(Hz)和符号频率Fd(Hz)。这个
%Y的采样频率为Fs(Hz),其中Fs>Fc,其中Fs/Fd为
%一个正整数。有关方法和后续步骤的信息
%参数,以及关于使用特定调制技术,
%在MATLAB提示符处键入以下命令之一:
%
%有关详细信息,请参阅类型调制技术
%dmod ask%M进制振幅移位键控调制
%dmod-psk%M元相移键控调制
%dmod-qask%M进制正交幅度移位键控
%%调制
%dmod-fsk%M进制频移键控调制
%dmod msk%最小移位键控调制
%
%对于基带模拟,使用DMODCE。要绘制信号星座,
%使用MODMAP。
%
%另请参见DDEMOD、DMODCE、DDEMODCE、MODMAP、AMOD、ADEMOD。
%版权所有1996-2007 MathWorks公司。
%$Revision:1.1.6.5$$日期:2007/06/08 15:53:47$
WarnObserve(mfilename,“请改用MODEM.PAMMOD、MODEM.qamod、MODEM.genqamod、FSKMOD、MODEM.PSKMOD或MODEM.MSKMOD”。);
swqaskenco=警告(“关闭”,“通信:过时:qaskenco”);
swapkconst=警告(“关闭”,“通信:过时:apkconst”);
swmodmap=警告('off'、'comm:过时:modmap');
swamod=警告('off'、'comm:过时:amod');
选择位置=6;%第一个可选参数的位置
如果nargout>0
y=[];t=[];
结束
如果nargin<1
feval('help','dmod'))
返回;
elseif isstr(x)
方法=较低(去白(x));
如果长度(方法)<3
错误('DMOD的方法选项无效')
结束
如果nargin==1
%个别调制方法的帮助行。
加法='另见DDEMOD、DMODCE、DDEMODCE、MODMAP、AMOD、ADEMOD';
如果方法(1:3)=‘qas’
呼叫帮助(“dmod.hlp”,方法(1:4),添加);
其他的
呼叫帮助(“dmod.hlp”,方法(1:3),添加);
结束
其他的
%绘制星座图,做出改变。
选择位置=选择位置-3;
M=Fc;
如果nargin>=opt_pos
opt2=Fd;
其他的
modmap(方法M);
返回;
结束
如果nargin>=opt_pos+1
opt3=Fs;
其他的
modmap(方法M,opt2);
返回;
结束
modmap(方法,M,opt2,opt3);%图星座
结束
返回;
结束
if(nargin<4)
错误('用法:Y=DMOD(X,Fc,Fd,Fs,METHOD,OPT1,OPT2,OPT3)用于通带调制';
埃尔塞夫·纳金1
初始相位=Fs(2);
Fs=Fs(1);
其他的
初始相位=0;%默认初始阶段
结束
如果~isfinite(Fs)| ~isreal(Fs)| Fs看起来dmod不再是:-)
下面是一个链接,上面说它已被删除:
http://www.mathworks.com/help/comm/release-notes.html?searchHighlight=dmod
它应该替换为comm.fsk调制系统对象AFAIK,Matlab或任何官方工具箱中都没有
dmod
函数。@OliCharlesworth:但我的练习报告说有。我还有其他选择吗?Thanks@OliCharlesworth-看看这个matlab论坛帖子:,我猜有dmod,唯一的问题是matlab 2012支持dmod吗?谢谢你的帮助,但是如果我更改do demod,它会显示太多的输入参数。准确地说,我需要一个FSK功能-频移键控和方向是模块化的行动。之后,我将进行解调,但我确实发现了类似comm.fsk调制系统对象的东西。您是wright,它从2011年版的Matlab中删除。但在极端需要的情况下,您仍然可以评估使用我发布的函数的想法。