9-4 �x�}��������ƫ��A

¤@¯ë¯x°}ªº¤º³¡¸ê®Æ«¬ºA³£¬O¹w³]¦¨ double¡]Âùºë·Ç¯BÂI¼Æ¡^¡A¦ý¦b MATLAB 5.3 ª©¤§«á¡A¤]¤ä´©¤£¦Pªø«×ªº¾ã¼Æ»P¯BÂI¼Æ¸ê®ÆºA¡A¾ã²z¦p¤Uªí¡G

«ü¥O»¡©ú
uint8 Âà´«¦¨¤£±a¥¿­t¸¹¡B 8 ¦ì¤¸ªº¾ã¼Æ¡A¨ä­È°ì¬° $[0, 2^{8}-1]=[0,255]$
uint16 Âà´«¦¨¤£±a¥¿­t¸¹¡B16 ¦ì¤¸ªº¾ã¼Æ¡A¨ä­È°ì¬° $[0, 2^{16}-1]=[0,65535]$
uint32 Âà´«¦¨¤£±a¥¿­t¸¹¡B32 ¦ì¤¸ªº¾ã¼Æ¡A¨ä­È°ì¬° $[0, 2^{32}-1]$
int8 Âà´«¦¨±a¥¿­t¸¹¡B 8 ¦ì¤¸ªº¾ã¼Æ¡A¨ä­È°ì¬° $[-2^{7}, 2^{7}-1]=[-128,127]$
int16 Âà´«¦¨±a¥¿­t¸¹ ¡B 16 ¦ì¤¸ªº¾ã¼Æ¡A¨ä­È°ì¬° $[-2^{15}, 2^{15}-1]=[-32768,32767]$
int32 Âà´«¦¨±a¥¿­t¸¹ ¡B 32 ¦ì¤¸ªº¾ã¼Æ¡A¨ä­È°ì¬° $[-2^{31}, 2^{31}-1]$
single Âà´«¦¨ single¡]³æºë·Ç¯BÂI¼Æ¡^¡A¦û¥Î 32 ¦ì¤¸¡]4 bytes¡^
double Âà´«¦¨double ¡]Âùºë·Ç¯BÂI¼Æ¡^¡A¦û¥Î 64 ¦ì¤¸¡]8 bytes¡^
char Âà´«¦¨¦r¤¸©Î¦r¦ê¡A¨C­Ó¦r¤¸¦û¥Î¡]16 ¦ì¤¸¡^¡]2 bytes¡^

¦]¦¹¡A¦pªG§Ú­Ì­n¸`¬Ù°O¾ÐÅéªÅ¶¡¡A´N¥i¥H¨Ì¯x°}¤¸¯À­Èªº½d³ò¡A¿ï¥Î¤£¦Pªº¸ê®Æ¨ÓÀx¦s¡A¨Ò¦p¡G

Example 1: 09-¯x°}ªº³B²z»P¹Bºâ/dataType01.mclear all % ²M°£©Ò¦³¤u§@ªÅ¶¡ªºÅÜ¼Æ x_double = magic(10); x_single = single(x_double); x32 = uint32(x_double); x16 = uint16(x_double); x8 = uint8(x_double); whos Name Size Bytes Class Attributes x16 10x10 200 uint16 x32 10x10 400 uint32 x8 10x10 100 uint8 x_double 10x10 800 double x_single 10x10 400 single

¥Ñ¤W¥iª¾¡A¨Ï¥Î uint8 ¨ÓÀx¦sÅܼƩҦûªºªÅ¶¡¥u¦³ double ªº¤K¤À¤§¤@¡C¦ý¬O­nª`·Nªº¬O¡G¾ã¼Æ¸ê®Æ«¬ºAªº½d³ò¦³­­¡A­Y¶W¹L¦¹½d³ò¡A«h¶W¥X³¡¤À±N·|³Q¡uµô±¼¡v¡A¨Ò¦p¡G

Example 2: 09-¯x°}ªº³B²z»P¹Bºâ/dataTypeRange01.mfprintf('uint8(300) ='); disp(uint8(300)); % uint8 ªº³Ì¤j­È¬° 255 fprintf('int8(-500) ='); disp(int8(-500)); % int8 ªº³Ì¤p­È¬° -128uint8(300) = 255 int8(-500) = -128


MATLABµ{¦¡³]­p¡G¤Jªù½g