Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Léon
Léon le 9 Déc 2011
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!

Réponse acceptée

Jan
Jan le 9 Déc 2011
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.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB Compiler dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by