11-2 �h���}�C���إ�

­Y­n«Ø¥ß¤@­Ó²³æªº¦hºû°}¦C¡A¥iª½±µ¸g¥Ñ MATLAB «ü¥Oµøµ¡¤º¿é¤J¡A¨Ò¦p

Example 1: 11-¦hºû°}¦C/mDim01.mA = [1 0 2 5; 4 1 8 7; 3 2 6 3]; A(:, :, 2) = [3 5 4 1; 2 6 2 1; 4 2 3 0] A(:,:,1) = 1 0 2 5 4 1 8 7 3 2 6 3 A(:,:,2) = 3 5 4 1 2 6 2 1 4 2 3 0

¦b¤W¨Ò¤¤¡A¬O¥ý«Ø¥ß¤@­Ó¤Gºû°}¦C A ¡A¦A¿é¤J²Ä¤G­¶ªº¤Gºû°}¦C A(¡G,¡G,2) ¡A¨Ì¦¹¤è¦¡³v­¶¿é¤J¤Gºû°}¦Cªº¤º®e¡A§Y¥i«Ø¥ß¤Tºû°}¦C¡C¦pªGª½±µ³]©w¬Y¤@­Ó·s­¶ªº¤@­Ó¤¸¯À­È¡A¦¹®ÉMATLAB ·|±N¦¹­¶¨ä¥L¥¼«ü©w¤§¤¸¯Àª½±µ³]©w¬° 0 ¡A¨Ò¦p¡G

Example 2: 11-¦hºû°}¦C/mDim02.mA=[1 0 2 5; 4 1 8 7; 3 2 6 3]; A(:, :, 2)=[3 5 4 1; 2 6 2 1; 4 2 3 0]; A(2, 1, 3)=5; disp(A); (:,:,1) = 1 0 2 5 4 1 8 7 3 2 6 3 (:,:,2) = 3 5 4 1 2 6 2 1 4 2 3 0 (:,:,3) = 0 0 0 0 5 0 0 0 0 0 0 0

§Ú­Ì¤]¥i¥H¨Ï¥Î MATLAB ªº¯Â¶q®i¶}¡]Scalar Expansion¡^ªº¥\¯à¡Aª½±µ³]©w¤@­Ó¯Â¶qµ¹¦hºû°}¦Cªº¤@­¶¡A¨Ò¦p¡A­Y­n±N°}¦C A ªº²Ä¤G­¶ªº©Ò¦³¤¸¯À³]¬° 7¡A¥i¿é¤J¦p¤U¡G

Example 3: 11-¦hºû°}¦C/mDim03.mA=[1 0 2 5; 4 1 8 7; 3 2 6 3]; A(:, :, 2)=7; disp(A); (:,:,1) = 1 0 2 5 4 1 8 7 3 2 6 3 (:,:,2) = 7 7 7 7 7 7 7 7 7 7 7 7

¹ï©ó¸û½ÆÂøªº¦hºû°}¦C¡A¥i¥Î cat «ü¥O¨Ó«Ø¥ß¡A¨ä¥\¯à¬°¡u¨Ã±Æ¡v¼Æ­Ó°}¦C¡A¨Ã¥i«ü©w¡u¨Ã±Æ¡v®É©Ò¥Îªººû«×¡A¨ä«ü¥O®æ¦¡¦p¤U¡G

Z = cat(dim, A, B, C¡K)

¨ä¤¤ A¡BB¡BC ¬°°}¦C¡Adim ¬O±N A¡BB¡BC¡K ¦X¨Ö®É©Ò¥Î¨ìªººû«×¡C¨Ò¦p¡G±ý±N¯x°} A »P B ¤W¤U¡]««ª½¡^¨Ã±Æ¡A¥i¿é¤J¡G

Example 4: 11-¦hºû°}¦C/cat01.mA = [1 2; 3 4]; B = [1 0; 0 1]; Z = cat(1, A, B) % ¼Æ¦r 1 ªí¥Ü±N°}¦C A »P B ¤W¤U««ª½¨Ã±Æ Z = 1 2 3 4 1 0 0 1

­Y±ý±N°}¦C A »P B ¥ª¥k¡]¤ô¥­¡^¨Ã±Æ¡A¥i¿é¤J¡G

Example 5: 11-¦hºû°}¦C/cat02.mA = [1 2; 3 4]; B = [1 0; 0 1]; Z = cat(2, A, B) % ¼Æ¦r 2 ªí¥Ü±N°}¦C A »P B ¥ª¥k¤ô¥­¨Ã±Æ Z = 1 2 1 0 3 4 0 1

­Y±ý±N°}¦C A »P B Å|°_¨Ó¡A¥H±o¨ì¤@­Ó¤Tºû°}¦C¡A¥i¿é¤J¡G

Example 6: 11-¦hºû°}¦C/cat03.mA = [1 2; 3 4]; B = [1 0; 0 1]; Z = cat(3, A, B) % ¼Æ¦r 3 ªí¥Ü±N°}¦C A »P B ­«Å|±Æ¦¨¤Tºû°} Z(:,:,1) = 1 2 3 4 Z(:,:,2) = 1 0 0 1

­Y©Ò³]©wªº dim ­È¤ñ°}¦C A¡BB¡BC¡Kªº¦U¦Û­ì¥ýªº¡uºû«×¼Æ¡v¡]Dimensionality¡^ÁÙ­n¶W¥X 2 ©Î§ó¦h¡A«h MATLAB ·|¦Û°Ê¸É¤W¤j¤p¬° 1 ªººû«×¡A¨Ò¦p¡G

Example 7: 11-¦hºû°}¦C/cat04.mA = [1 2; 3 4]; B = [1 0; 0 1]; Z = cat(4, A, B) % ¼Æ¦r 4 ªí¥Ü±N°}¦C A »P B ©ñ¦b¬Û¾Fªº¨â¡u½c¡v Z(:,:,1,1) = 1 2 3 4 Z(:,:,1,2) = 1 0 0 1

¦¹®É°}¦C Z ªººû«×Åܬ° 2¡Ñ2¡Ñ1¡Ñ2¡C¡]ŪªÌ¥i¥H·Q¹³³o¬O¤À¦¨¨â½cªº¦hºû°}¦C¡A¨C¤@½c¦U¦³¤@­¶¡A¨C¤@­¶³£¬O 2¡Ñ2 ªº¯x°}¡C ¡^

MATLAB ¥ç¥i²£¥Í¯S®í¥Î³~ªº¦hºû°}¦C¡A¨Ò¦p¡G­Y­n²£¥Í¤@­Óºû«×¬O 2¡Ñ3¡Ñ5 ªº¶Ã¼Æ°}¦C¡A¥i¥Î rand «ü¥O¡G

Example 8: 11-¦hºû°}¦C/rand01.mA=rand(2,3,4) A(:,:,1) = 0.8147 0.1270 0.6324 0.9058 0.9134 0.0975 A(:,:,2) = 0.2785 0.9575 0.1576 0.5469 0.9649 0.9706 A(:,:,3) = 0.9572 0.8003 0.4218 0.4854 0.1419 0.9157 A(:,:,4) = 0.7922 0.6557 0.8491 0.9595 0.0357 0.9340

Ãþ¦üªº«ü¥O¡AÁÙ¦³ randn¡Bones¡Bzeros µ¥¥Î¨Ó²£¥Í¯S®í¥Î³~ªº¯x°}¡A¸Ô¨£¥»®Ñ²Ä¤E³¹¡u¯x°}ªº³B²z»P¹Bºâ¡vªº²Ä¤G¸`¡u¯S®í¥Î³~¯x°}¡v¡C


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