フィルターのクリア

Alternative to any() for loops when compiling mex-functions

1 回表示 (過去 30 日間)
Léon
Léon 2011 年 12 月 9 日
Does anyone know the best alternative to the any() function when I use it in a loop, since it is not supported for compiling the m-code as a mex-function. Example:
if any(k)
x = k^2;
end;
Thank you very much!

採用された回答

Jan
Jan 2011 年 12 月 9 日
What about a dull loop?
any_k = false;
for i = 1:numel(k)
if k(i) ~= 0
any_k = true;
break;
end
end
If this is converted to C, it should ve efficient. But I cannot test this.
  1 件のコメント
Léon
Léon 2011 年 12 月 12 日
Thanks, very good hint! :-)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Compiler についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by