我正在測試我在MATLAB中工作的一部分函數。我已經定義的函數和子功能(只是用於測試)如下:輸入參數未定義 - 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
時出錯和錯誤的地方!
我再次得到相同的錯誤! '???未定義的函數或變量'ld'。 錯誤==> funct> dirvar at 14 h = length(EW) - ld 錯誤==> nlfilter at 61 b = mkconstarray(class(feval(fun,aa(1 + rows,1 + cols ),params {:})),0,size(a)); 錯誤==> funct at 6 A = nlfilter(I,[7 7],@dirvar); ' – 2011-04-17 06:08:06