Clean it up from successive calculation

1 view (last 30 days)
Philosophaie
Philosophaie on 13 Feb 2014
Answered: Iain on 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".

Answers (1)

Iain
Iain on 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.

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!