logical matrix divided by double matrix is slow
Afficher commentaires plus anciens
a=logical(12,90,111);
b=randi(100,[12,90,111]);
c = a ./ (b+1e-10).
This line seems a very simple operation but it is so time-consuming. I am wondering if any speed up can be done?

Réponse acceptée
Plus de réponses (1)
Image Analyst
le 21 Mai 2018
What is the last line in your post???
When I run your code I get this:
Error using logical
Too many input arguments.
Error in test2 (line 1)
a=logical(12,90,111);
When I do this:
a=false(12,90,111);
b=randi(100,[12,90,111]);
tic;
c = a ./ (b+1e-10);
toc
I get
Elapsed time is 0.000511 seconds.
which seems pretty fast to me. What are you doing differently?
2 commentaires
Chaoyang Jiang
le 21 Mai 2018
Image Analyst
le 21 Mai 2018
Well change it to false, which is also a logical, and it will run so much faster.
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!