程式设计入门篇.pptVIP

  • 2
  • 0
  • 约6.12千字
  • 约 36页
  • 2019-10-10 发布于湖北
  • 举报
Matlab MATLAB 程式設計入門篇 M檔案 張智星 jang@.tw .tw/~jang 清大資工系 多媒體檢索實驗室 15-1 底稿 底稿(Script) 副檔名為m的檔案,包含 MATLAB各種指令 在MATLAB指令視窗直接輸入檔名,即逐一執行檔案內的指令 M檔案的顯示 在目前目錄下有一個M檔案“script01.m”,可用 type 指令顯示其內容: cd ’d:\ matlabBook\MATLAB程式設計:入門篇\15-M檔案’ type script01.m ? clear all % 清除所有變數 x = [1 4 -2 3 -1 -5]; for i = 1:length(x), if x(i)0, fprintf(x(%g) = %g is positive\n, i, x(i)); else fprintf(x(%g) = %g is negative or zero\n, i, x(i)); end end M檔案的執行 欲執行 script01.m, 在指令視窗下輸入 script01 即可 script01 x(1) = 1 is positive x(2) = 4 is positive x(3) = -2 is negative or zero x(4) = 3 is positive x(5) = -1 is

文档评论(0)

1亿VIP精品文档

相关文档