Matlab说函数中没有定义“find”

Matlab说函数中没有定义“find”,matlab,Matlab,在我的命令窗口中,我可以执行find[0 1 0],但当我在函数中运行find时,如在x=find[0 1 0]中,编译器告诉我find没有定义。为什么会这样 错误是: ??? Error: File: frequentTuples.m Line: 12 Column: 21 "find" previously appeared to be used as a function or command, conflicting with its use here as the name of

在我的命令窗口中,我可以执行find[0 1 0],但当我在函数中运行find时,如在x=find[0 1 0]中,编译器告诉我find没有定义。为什么会这样

错误是:

??? Error: File: frequentTuples.m Line: 12 Column: 21
 "find" previously appeared to be used as a function or command, conflicting with its
 use here as the name of a variable.
 A possible cause of this error is that you forgot to initialize the
 variable, or you have initialized it implicitly using load or eval.
这是代码。错误发生在for循环的第二行

function [ tuples ] = frequentTuples( k, candidates, transactions, min_support  )
%FREQUENTTUPLES Get frequent itemsets of size k
%   Detailed explanation goes here

candidate_tuple_is_frequent = zeros(size(candidates, 1));
for i = 1:size(candidates, 1)
    columns_of_candidate_items = transactions(:, candidates(i, :));
    indices_of_transactions_containing_all_items = find(sum(columns_of_candidate_items') == k);
    candidate_tuple_is_frequent(i) = size(indices_of_transactions_containing_all_items) >= min_support;
end

tuples = candidates(find(candidate_tuple_is_frequent, :));

end

啊,我现在明白你的问题了。第13行的括号放错了位置。你有

tuples = candidates(find(candidate_tuple_is_frequent, :));
你应该什么时候去

tuples = candidates(find(candidate_tuple_is_frequent), :);

您试图调用findcandidate\u tuple\u is\u frequency,:,它试图将find视为变量。这意味着要在函数中查找的任何其他调用都会将其视为变量,因此会出现错误。

您能发布您收到的确切代码和错误消息吗?我看不出您显示的代码中会出现错误的原因,在将来,如果您将其作为代码而不是图片包含会更好—这会使复制代码进行测试变得相当困难。出于好奇,如果用变量替换[0 1],错误是否会一直存在?我猜图像并没有显示函数的所有代码,有些代码也被工具提示隐藏了,并且您在某个地方定义了一个名为find的函数变量。@horchler:我不相信是这样的,因为功能范围显然从第1行开始,到第15行结束。其他地方定义的变量不应影响显示的代码。第8行的警告看起来很奇怪。