2009年2月25日 星期三

FORMAT Set output format

利用 format 指令, 可以更改預設的數值顯示方式。
FORMAT with no inputs sets the output format to the default appropriate for the class of the variable. For float variables, the default is FORMAT SHORT.

FORMAT does not affect how MATLAB computations are done. Computations on float variables, namely single or double, are done in appropriate floating point precision, no matter how those variables are displayed. Computations on integer variables are done natively in integer. Integer variables are always displayed to the appropriate number of digits for the class, for example, 3 digits to display the INT8 range -128:127.

FORMAT SHORT and LONG do not affect the display of integer variables.

FORMAT may be used to switch between different output display formats of all float variables as follows:

FORMAT SHORT Scaled fixed point format with 5 digits.

FORMAT LONG Scaled fixed point format with 15 digits for double and 7 digits for single.

FORMAT SHORT E Floating point format with 5 digits.

FORMAT LONG E Floating point format with 15 digits for double and 7 digits for single.

FORMAT SHORT G Best of fixed or floating point format with 5 digits.

FORMAT LONG G Best of fixed or floating point format with 15 digits for double and 7 digits for single.

FORMAT SHORT ENG Engineering format that has at least 5 digits and a power that is a multiple of three

FORMAT LONG ENG Engineering format that has exactly 16 significant digits and a power that is a multiple of three.

FORMAT may be used to switch between different output display formats of all numeric variables as follows:

FORMAT HEX Hexadecimal format.

FORMAT + The symbols +, - and blank are printed for positive, negative and zero elements. Imaginary parts are ignored.

FORMAT BANK Fixed format for dollars and cents.

FORMAT RAT Approximation by ratio of small integers.

FORMAT may be used to affect the spacing in the display of all variables as follows:

FORMAT COMPACT Suppresses extra line-feeds.

FORMAT LOOSE Puts the extra line-feeds back in.

 

沒有留言:

張貼留言