Declaring types in MATLAB
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Fernando Riveiro Formoso
el 16 de Mayo de 2020
Comentada: Walter Roberson
el 18 de Mayo de 2020
When preallocating, is it possible to declare types?
If so, how can I do it? Is it worthy in terms of efficiency?
0 comentarios
Respuesta aceptada
Stephen23
el 16 de Mayo de 2020
Editada: Stephen23
el 16 de Mayo de 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 comentarios
Walter Roberson
el 18 de Mayo de 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/
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!