Declaring types in MATLAB
조회 수: 2 (최근 30일)
이전 댓글 표시
When preallocating, is it possible to declare types?
If so, how can I do it? Is it worthy in terms of efficiency?
댓글 수: 0
채택된 답변
Stephen23
2020년 5월 16일
편집: Stephen23
2020년 5월 16일
"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
Walter Roberson
2020년 5월 18일
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/
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!