Single-precision unit-spaced vector without conversion from double
显示 更早的评论
Hi,
is there a fast way to create a unit-spaced vector (m:n) as single precision, and avoid conversion from double?
I want to avoid out-of-memory related errors. The following method may fail (with a "Conversion to single from double is not possible." error) if k is very large.
m = 0;
n = 10;
k=n-m+1;
x = zeros(k,1,'single');
x(1:k) = m:n;
I guess, it is not different, or perhaps even worse (double both for the vector AND for the index) than doing simply
x = single(m:n);
I'd like to generate each element of m:n already as single precision. One approach that comes to my mind is to divide the vector into parts and fill each part by conversion from a smaller double vector.
Is there any better method?
Thanks!
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!