Declaring types in MATLAB
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Fernando Riveiro Formoso
le 16 Mai 2020
Commenté : Walter Roberson
le 18 Mai 2020
When preallocating, is it possible to declare types?
If so, how can I do it? Is it worthy in terms of efficiency?
0 commentaires
Réponse acceptée
Stephen23
le 16 Mai 2020
Modifié(e) : Stephen23
le 16 Mai 2020
"When preallocating, is it possible to declare types? "
When preallocating you can select any suitable data type, e.g.:
A = zeros(2,3, 'uint8')
Read the zeros, ones, nan documentation to know more.
"Is it worthy in terms of efficiency?"
In most cases preallocation is more efficient than not preallocating.
4 commentaires
Walter Roberson
le 18 Mai 2020
datatype can make a big difference, but which is faster can depend upon the processor. There are a range of processors for which single is always faster than double, but then there can be oddities like double multiplication being faster.
http://nicolas.limare.net/pro/notes/2014/12/12_arit_speed/
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!