Clean it up from successive calculation
4 次查看(过去 30 天)
显示 更早的评论
I have an array and I want to clean it up from successive calculation:
for i=1
for j=1:4
for k=1:4
B(i,j,k)=double(A(i,j,k))
end
end
end
A is a 4x4x4 matrix and contain a diversity of numbers from 1E-9 to 1E+9.
I need a format other than "double" to show all the decimal places 0.0000000001 and all the zeroes 1000000000.
Or could you send me a link of all the formats like "double".
0 个评论
回答(1 个)
Iain
2014-2-13
Data formats tell you what the data represents. Doubles are actually the best, commonly used, method to store signed numbers with amplitudes between 10^-300ish to 10^300ish.
It looks like you want to store or display the numeric values, as strings.
To store them, you can explicitly use sprintf, with the correct c-style string notation to return the values in a string format that has the correct amount of precision.
To display them you can explicitly use fprintf/sprintf, with the correct c-style string notation to return the values in a string format that has the correct amount of precision. Or, you can change matlab's default way of displaying numbers to "long" (though, that only handles up to 8 significant figures).
If you can't get the numbers into a string using those methods, in the format you want, you can, with the right intelligence, write a function to take a number and return it as you want.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!