[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: Formatting of digits across columns

**From**: |
Andreas Weber |

**Subject**: |
Re: Formatting of digits across columns |

**Date**: |
Sun, 27 Oct 2013 12:17:37 +0100 |

**User-agent**: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130922 Icedove/17.0.9 |

Am 26.10.2013 12:01, schrieb João Rodrigues:
>* I want to write a matrix with real numbers to an ASCII file so that the*
>* maximum number of digits is always approximately the same and in each*
>* column the number of decimal places is the same.*
>* *
>* For example, if n = 4:*
>* *
>* 17.6 3.01 6.754*
>* 70.0 4.27 0.294*
>* 196.0 15.03 0.043*
>* *
>* I can do something like:*
>* *
>* dlmwrite(matrix,"delimiter", "\t", "precision","%10.2f") but then I need*
>* to know exactly how many decimal places there will be, and the same*
>* value will apply to all columns.*
>* *
>* dlmwrite(matrix,"delimiter", "\t", "precision",4) will yield a maximum*
>* of 4 digits per entry, but will not fill in the extra digits so that the*
>* number of decimal places per column is always the same.*
Dear Joao, please dont hijack threads.
(http://www.urbandictionary.com/define.php?term=thread+hijacking)
I'm not sure if I understand your question so please provide some smaple
matrix and your desired output.
Just a wild guess what you want:
octave:1> a=rand(4,3)*100, printf("%5.2f\t%.3f\t%.1f\n",a')
a =
89.15902 73.22400 81.72654
80.67683 52.45572 80.93744
82.50297 43.73875 10.93027
13.17486 0.15580 5.45265
89.16 73.224 81.7
80.68 52.456 80.9
82.50 43.739 10.9
13.17 0.156 5.5
Regards, Andy