2011-01-13 10 views
-2

次のコードを実行すると、未定義の関数または変数 'Test_x'がエラーになります。なぜこのエラーが発生しますか?以下は'定義されていない関数または変数'を解決する方法

私はこれまでのところ、

for D=max(max(X))       % Find max value     
    if D >= 5      % For only when at least one value >= the threshold 

    sumx=conv2(X,kernel,'same');   % Compute the sum of neighbors for each pixel 
    nx=conv2(double(X>0),kernel,'same'); % Compute the number of non-zero neighbors   
    avg_x=X; 
    avg_x(avg_x<5)=0;      
    index=(avg_x>=5);      % Find logical index of pixels >=40 
    avg_x(index)=sumx(index)./max(nx(index),1); % Center or average of the nonzeros 
    avg_x1=(avg_x>0); 

    tmp_x=avg_x; 
    maxVal=max(avg_x(:))+1; 
    tmp_x(tmp_x==0)=maxVal; % Replace all the zeros in the tmp_Z1 with a larger value 
    tmp_x=imerode(tmp_x,kernel); 

    Test_x=X>=tmp_x;      % Put one wherever new_Z1(k)>=tmp_Z1(k) 
    Test=Test_x+avg_x1;     
    Test_X=(Test>0); 

    elseif D<5        % Use when there is no value >= threshold 
     Test_X=Test_x.*avg_x1;    % Give Zero matrix 

    end 
end 

は、すべてのあなたの助け:)

答えて

1

Dの初期値が小さければ、あなたのコード内のエラー??? Undefined function or variable 'Test_x'.を取得するためにあなたに感謝しているものです5より大きい場合は、最初にTest_xに何も設定せずに、最後の行Test_X=Test_x.*avg_x1;を実行します。 avg_x1も同様に初期化する必要があります。そうでなければ、その変数に対して同じエラーが発生します。

+0

ありがとうございました..私はちょうどそれらを修正しました.. – Nadhris

関連する問題