Is it possible to automatically comment few lines of matlab code after sometime while the code is running ?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ravi Lakshay
le 15 Juin 2017
Commenté : Ravi Lakshay
le 15 Juin 2017
Is it possible to automatically comment few lines of Matlab code after some time while the code is running? I think this will save execution time of my code, because I don't want Matlab to check 'if' condition everytime in a for loop once it is true.
Please help.
0 commentaires
Réponse acceptée
Guillaume
le 15 Juin 2017
No, it is not possible to modify code while it is running.
Unless your if expression is extremely complex, I wouldn't even worry about it. It's unlikely to be a bottleneck. And if it is a worry, the first thing to do is check that it is indeed a problem using a profiler.
If the if check is expensive you can always shortcircuit it:
checkpassed = false;
for ... %some loop
if checkpassed || someexpensivecheck
checkpassed = true;
%...
end
end
because of the shortcircuiting behaviour of ||, once checkpassed is true, someexpensivecheck is never run.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Solver Outputs and Iterative Display 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!