11-3 �h���}�C���B�z

³\¦h¥Î©ó¦V¶q©M¯x°}ªº¼Æ¾Ç¹Bºâ¡A¨Ò¦p sum¡Bmax¡Bmin¡Bmean µ¥¡A¤]³£¥i¥H¥Î¦b¦hºû°}¦C¡A¦ý¬O­n¯S§Oª`·N¡A¦b¨Ï¥Î³o¨Ç«ü¥O®É¡A§Ú­Ì¥²¶·«ü©w³o¨Ç«ü¥Oªº¾Þ§@¬O¦b­þ¤@­Óºû«×¡A¨Ò¦p¡G

Example 1: 11-¦hºû°}¦C/sum01.mA = [1 1 1 1; 2 2 2 2; 3 3 3 3]; B = [0 0 0 0; 1 1 1 1; 1 2 3 4]; Z = cat(3, A, B); % ±N¯x°} A, B Å|¦¨¤@­Ó¤Tºû°}¦C S = sum(Z, 1) % ®Ú¾Ú²Ä¤@ºû«×¨Ó¹ï¤¸¯À¶i¦æ¬Û¥[ size(S) S(:,:,1) = 6 6 6 6 S(:,:,2) = 2 3 4 5 ans = 1 4 2

¦b¤W­z½d¨Ò¤¤¡A¯x°} Z ªº¤j¤p¬O 3¡Ñ4¡Ñ2¡Asum(Z, 1) ¬O®Ú¾Ú²Ä¤@­Óºû«×¨Ó¶i¦æ¬Û¥[¡A¦]¦¹²Ä¤@­Óºû«×­È´N·|³QÀ£¦¨¬O 1¡A¦]¦¹ size(S) ©Ò¶Ç¦^ªº­È¬O [1, 4, 2]¡A¥Nªí¯x°} S ªº¤j¤p¬O 1¡Ñ4¡Ñ2¡C¦¹¥~¡Asum(Z) ªº¹w³]¬Û¥[ºû«×§Y¬O 1¡A¦]¦¹ sum(Z) ©M sum(Z, 1) ©Ò±o¨ìªºµ²ªG¬O¤@¼Ëªº¡C

­Y­n¹ï²Ä¤G­Óºû«×¶i¦æ¬Û¥[¡A¥i¨£¤U¦C½d¨Ò¡C

Example 2: 11-¦hºû°}¦C/sum02.mA = [1 1 1 1; 2 2 2 2; 3 3 3 3]; B = [0 0 0 0; 1 1 1 1; 1 2 3 4]; Z = cat(3, A, B); % ±N¯x°} A, B Å|¦¨¤@­Ó¤Tºû°}¦C S = sum(Z, 2) % ®Ú¾Ú²Ä¤Gºû«×¨Ó¹ï¤¸¯À¶i¦æ¬Û¥[ size(S) S(:,:,1) = 4 8 12 S(:,:,2) = 0 4 10 ans = 3 1 2

¦b¤W­z½d¨Ò¤¤¡Asum(Z, 2)¬O¹ï²Ä¤G­Óºû«×¶i¦æ¬Û¥[¹Bºâ¡A¦]¦¹©Ò¶Ç¦^ªº¯x°} S ªººû«×¬O 3¡Ñ1¡Ñ2¡C¡]¦b¥»®Ñªº½d¨Òµ{¦¡¤¤¡Asum03.m ¬O¹ï Z ªº²Ä¤T­Óºû«×¶i¦æ¬Û¥[¹Bºâ¡A½ÐŪªÌ¦Û¤v¸Õ¸Õ¬Ý¡C¡^

¦b¤W­z½d¨Ò¤¤¡A§Ú­Ì¥i¥H·Q¹³ S = sum(Z, 1) ¬O¥ý§@¥Î¦b Z ªº¨C¤@­¶¡AµM«á¦A±Nµ²ªG°ïÅ|°_¨Ó¡A¦¨¬°¤@­Ó¤Tºû°}¦C S¡C¦P¼Ëªº·Qªk¡A¤]¥i¥HÀ³¥Î¦b S = sum(Z, 2)¡C

­nª`·Nªº¬O¡A¦pªG©Ò­n¬Û¥[ªººû«×¥u¦³³æ¤@ºû«×¡A¨º»ò sum «ü¥O·|¹ï¤U¤@­Óºû«×¶i¦æ¬Û¥[ªº°Ê§@¡A¦]¦¹¡]©Óŧ¤W­z½d¨Ò¡^sum(sum(Z)) ±N·|±o¨ì¤Tºû°}¦C Z ªº¨C¤@­¶ªºÁ`©M¡A½Ð¨£¤U¦C½d¨Ò¡C

Example 3: 11-¦hºû°}¦C/sumSum01.mA = [1 1 1 1; 2 2 2 2; 3 3 3 3]; B = [0 0 0 0; 1 1 1 1; 1 2 3 4]; Z = cat(3, A, B); % ±N¯x°} A, B Å|¦¨¤@­Ó¤Tºû°}¦C S = sum(sum(Z)) S(:,:,1) = 24 S(:,:,2) = 14

¦P²z¡A­Y­n±o¨ì°}¦C Z ªº©Ò¦³¤¸¯ÀÁ`©M¡A¥i¥Î sum(sum(sum(Z))) ©Î¬O sum(Z(:))¡A¦b¦¹¤£¦AÂØ­z¡C

»P sum Ãþ¦üªº«ü¥OÁÙ¦³ max¡Bmin¡Bmean¡Bmedian¡Bmode¡Bstd¡Bdiff¡Bsort µ¥¡AŪªÌ¥i¥H°Ñ¦Ò¥»®Ñ²Ä¤E³¹¡u¯x°}ªº³B²z»P¹Bºâ¡vªº²Ä¤T¤p¸`¡u¯x°}ªº¼Æ¾Ç¹Bºâ¡v¡C


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