Clean it up from successive calculation

1 Ansicht (letzte 30 Tage)
Philosophaie
Philosophaie am 13 Feb. 2014
Beantwortet: Iain am 13 Feb. 2014
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".

Antworten (1)

Iain
Iain am 13 Feb. 2014
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.

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by