9-2 �G����l�I�����k

MATLAB ªº interp2 «ü¥O¥i¶i¦æ¤Gºû®æ¤lÂI¤º´¡¡A¨ä¨Ï¥Î»yªk¦p¤U¡G

zi = interp2(x, y, z, xi, yi, method)

¨ä¤¤ z ¬O¤@¯x°}¡A¥Nªí¤@¨ç¼Æªº°ª«×¡A¦Ó¯x°} x ¤Î y «h¬O¦¹¨ç¼Æ¦b¤è®æ¤lÂIªº x ¤Î y ®y¼Ð¡A¯x°} xi ¤Î yi «h¬O¤º´¡ÂIªº x ¤Î y ®y¼Ð¡A¦r¦ê method «h«ü©w¨Ï¥Îªº¤º´¡ªk¡A¦³ 4 ºØ¡G

¨Ï¥Î interp2 ®É¡Ax ¤Î y ³£¥²¶·¬OÄY®æ»¼¼W©Î»¼´î¡C¤@¯ë±¡ªp¤U¡Ax ¤Î y ³£¬O¥Ñ meshgrid ©Ò²£¥Í¡A¥H«OÃÒ¨ä®æ¦¡ªº¥¿½T©Ê¡C

¥Î¤£¦Pªº¤èªk¶i¦æ¤Gºû¤º´¡¡A·|±o¨ì¤£¦Pªº®ÄªG¡A¥H¤U§Ú­Ì¨Ï¥Î¦±­±¹Ï¤Îµ¥°ª½u¨ÓÅã¥Ü¤£¦P¤º´¡ªk©Ò±o¨ìªº¤£¦Pµ²ªG¡G

Example 1: 09-¤º´¡ªk/interp201.m[x,y] = meshgrid(-3:1:3); % ²£¥Í -3 ¦Ü 3 ªº®æ¤lÂI z = peaks(x,y); % ²£¥Í peaks ¦±­±¸ê®Æ [xi, yi] = meshgrid(-3:.25:3); % ¥Í²£¤º´¡ÂI zi1 = interp2(x, y, z, xi, yi, 'nearest'); zi2 = interp2(x, y, z, xi, yi, 'linear'); zi3 = interp2(x, y, z, xi, yi, 'cubic'); zi4 = interp2(x, y, z, xi, yi, 'spline'); subplot(2,3,1); surf(x, y, z); axis tight; title('Original'); subplot(2,3,3); surf(xi, yi, zi1); axis tight; title('Nearest'); subplot(2,3,4); surf(xi, yi, zi2); axis tight; title('Linear'); subplot(2,3,5); surf(xi, yi, zi3); axis tight; title('Cubic'); subplot(2,3,6); surf(xi, yi, zi4); axis tight; title('Spline'); % ¥H¤Uµe¥Xµ¥°ª½u figure subplot(2,3,1); contour(x, y, z, 20); title('Original'); subplot(2,3,3); contour(xi, yi, zi1, 20); title('Nearest'); subplot(2,3,4); contour(xi, yi, zi2, 20); title('Linear'); subplot(2,3,5); contour(xi, yi, zi3, 20); title('Cubic'); subplot(2,3,6); contour(xi, yi, zi4, 20); title('Spline');

¥Ñ¤W¨â¹Ï¥i¬Ý¥X¡Amethod = 'cubic' ²£¥Íªº¦±­±¸û¨ä¥¦¨âºØ¤èªk¡]'nearest' ¤Î 'linear'¡^¬°¥­·Æ¡C­Y¨Ï¥Î 'spline' ¤]·|²£¥Í¥­·Æªº¦±­±¡A³o³¡¤À½ÐŪªÌ­×§ï¤W­z½d¨Òµ{¦¡¡A¦Û¦æ¸Õ¸Õ¬Ý¡C


MATLABµ{¦¡³]­p¡G¶i¶¥½g