12-2 Excel �ɮת��g�J

¦bMATLAB ­pºâ±o¨ìªº¸ê®Æ¡A¤]¥i¥H¼g¤J xls ¤u§@ªí¡A«K©ó¶i¦æ¸ê®ÆªºÀx¦s¡B¤À¨É©Î§@¹Ï¤ÀªR¡C¼g¤J¤u§@ªí©Ò¥Î¨ìªº«ü¥O¬O xlswrite¡A°ò¥»½d¨Ò¦p¤U¡G

Example 1: 12-»PExcel¸Õºâªíªº¾ã¦X/xlswrite01.mxlsFile = 'output01.xls'; xlswrite(xlsFile, randn(5)); dos(['start ' xlsFile]);

¦b¤W­z½d¨Ò¤¤¡A§Ú­Ì±N¤@­Ó 5x5 ªº¶Ã¼Æ¯x°}¼g¤J Excel ÀÉ®×output01.xls¡]¥Ñ©ó§Ú­Ì¨Ã¥¼«ü©w¤u§@ªí¦WºÙ¡A©Ò¥H MATLAB ·|±N¸ê®Æª½±µ¼g¨ì¹w³]ªº Sheet1 ¤u§@ªí¡^¡A¨Ãª½±µ¶}±Ò¦¹ÀɮסA©Ò±o¨ìªºµøµ¡¦p¤U¡G

¦b¨Ï¥Î xlswrite ¼g¤J¸ê®Æ®É¡A¤]¥i¥H«ü©w¤u§@ªíªº¦WºÙ¡A©Î¬O«ü©w¼g¤Jªº¸ê®ÆÀx¦s®æ¡A½d¨Ò¦p¤U¡G

Example 2: 12-»PExcel¸Õºâªíªº¾ã¦X/xlswrite02.mxlsFile = 'output02.xls'; sheetName='7x7Å]¤è°}'; [status, message] = xlswrite(xlsFile, magic(7), sheetName) xlswrite(xlsFile, {'¥H¤W¬O7x7Å]¤è°}'; date}, sheetName, 'B8:B9'); dos(['start ' xlsFile]);status = 1 message = message: '' identifier: ''

¦b¤W­z½d¨Ò¤¤¡A§Ú­Ì±N¤@­Ó 7X7 ªºÅ]¤è°}¼g¤JÀÉ®× output02.xls¡]©Ò¦^¶Çªº status=1 ¥Nªí¼g¤J¦¨¥\¡Amessage «h¬O»¡©ú¬ÛÃöªº¾Þ§@¦WºÙ¡^¡A¨Ã±N¨â­Ó¦r¦ê¡]'¥H¤W¬O7x7Å]¤è°}' ¥H¤Î¥Ø«e¤é´Á¡^¤À§O¼g¤J B8:B9 ªº¸ê®ÆÀx¦s®æ¡A©Ò¶}±Òªº Excel µøµ¡¦p¤U¡G

¦b¤U¤@­Ó½d¨Ò¤¤¡A§Ú­Ì±N¦Û¥Ñ¸¨Å骺¸ê®Æ¡]¦ì¸m¹ï®É¶¡¡^¼g¤J¤@­Ó Excel ÀɮסA¦p¤U¡G

Example 3: 12-»PExcel¸Õºâªíªº¾ã¦X/xlswrite03.mxlsFile = 'output03.xls'; sheetName='¦ì¸m¹ï®É¶¡ªºÅܤÆ'; data={'®É¶¡ (sec)', '¦ì¸m (m)'}; for i=1:5 data{i+1,1}=i; data{i+1,2}=0.5*9.8*i^2; end [status, message] = xlswrite(xlsFile, data, sheetName); dos(['start ' xlsFile]);

©Ò¶}±Òªº Excel Àɮצp¤U¡G

Hint
  • ­Y­n¹ïLotus 123¸Õºâªí¶i¦æŪ¼g¡A¥i¥H¨Ï¥Îwk1read/wk1write¡C
  • ­Y­n¹ï¤@¯ëªº¤å¦rÀɮ׶i¦æÃþ¦üxlsread/xlswriteªº¥\¯à¡A¥i¥H¨Ï¥Îcsvread/csvwrite¥H¤Îdlmread/dlmwriteµ¥«ü¥O¡C
  • ­Y­n¬d¸ßMATLAB¥i¥HŪ¨úªº¦UºØÀɮ׮榡¡A¥i¥Ñ¡uhelp fileformats¡v¨Ó¨ú±o¬ÛÃöªº½u¤W¤ä´©¡C


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