【发布时间】:2011-04-17 05:54:10
【问题描述】:
我正在为我在 MATLAB 中的工作测试一个函数的一部分。我已经定义了一个函数和子函数如下(仅用于测试):
function funct
clear all;
clc;
I = rand(11,11);
ld = input('Enter the lag = ') % prompt for lag distance
A = nlfilter(I, [7 7], @dirvar);
% Subfunction
function [h] = dirvar(I, ld) %tried with function [h] = dirvar(I) as well,
%but resulted in same error
c = (size(I)+1)/2
EW = I(c(1),c(2):end)
h = length(EW) - ld
当我在命令窗口中以funct 运行该函数时,出现以下错误:
Enter the lag = 1
ld =
1
c =
4 4
EW =
0.0700 0.4073 0.9869 0.5470
??? Input argument "ld" is undefined.
Error in ==> funct>dirvar at 14
h = length(EW) - ld
Error in ==> nlfilter at 61
b = mkconstarray(class(feval(fun,aa(1+rows,1+cols),params{:})), 0, size(a));
Error in ==> funct at 6
A = nlfilter(I, [7 7], @dirvar);
当ld 被明确定义时,我无法弄清楚错误是什么以及在哪里!
【问题讨论】:
标签: matlab