MATLAB 7 William J Palm III 4 MATLAB
MATLAB 7 在 程上的應用 William J. Palm III 第 4章 MATLAB 程式設計 © The Mc. Graw-Hill Companies, Inc. , 2006
圖 4. 1– 1 電腦遊戲程式的結構圖。 © The Mc. Graw-Hill Companies, Inc. , 2006
圖 4. 1– 2 敘述的流程圖表示法。 © The Mc. Graw-Hill Companies, Inc. , 2006
表 4. 3– 1 邏輯運算子 © The Mc. Graw-Hill Companies, Inc. , 2006
表 4. 3– 2 運算子類型的優先順序 © The Mc. Graw-Hill Companies, Inc. , 2006
表 4. 3– 4 邏輯函數 (接下頁) © The Mc. Graw-Hill Companies, Inc. , 2006
表 4. 3– 4 邏輯函數(承上頁) (接下頁) © The Mc. Graw-Hill Companies, Inc. , 2006
圖 4. 4– 2 else 結構的流程圖。 © The Mc. Graw-Hill Companies, Inc. , 2006
圖 4. 4– 3 if-else 結構的流程圖。 © The Mc. Graw-Hill Companies, Inc. , 2006
圖 4. 4– 4 用以說明巢套if敘述的流程圖。 © The Mc. Graw-Hill Companies, Inc. , 2006
字串(承上頁) 下列的字串number和藉由輸入number = 123所建立出來 的變數number是不一樣的。 >>number = ’ 123’ number = 123 © The Mc. Graw-Hill Companies, Inc. , 2006
圖 4. 5– 1 for迴圈的流程圖。 © The Mc. Graw-Hill Companies, Inc. , 2006
continue 敘述 下列的程式碼使用continue敘述來避免計算到負數的對數。 x = [10, 1000, -10, 100]; y = Na. N*x; for k = 1: length(x) if x(k) < 0 continue end y(k) = log 10(x(k)); end y 此結果為 y = 1, 3, Na. N, 2。 更多相關資料請查詢課本第 4 -31~4 -32頁 © The Mc. Graw-Hill Companies, Inc. , 2006
圖 4. 5– 3 while迴圈的流程圖。 © The Mc. Graw-Hill Companies, Inc. , 2006
switch 結構的語法 switch 輸入算式(純量或者字串) case 值 1 敘述群組1 case 值 2 敘述群組2. . . otherwise 敘述群組 n end © The Mc. Graw-Hill Companies, Inc. , 2006
下列的switch段落顯示羅盤上對應至該角度的點。 switch angle case 45 disp(’Northeast’) case 135 disp(’Southeast’) case 225 disp(’Southwest’) case 315 disp(’Northwest’) otherwise disp(’Direction Unknown’) end 更多相關資料請查詢課本第 4 -42~4 -44頁 © The Mc. Graw-Hill Companies, Inc. , 2006
圖 4. 8– 2 註冊人數對時間的圖形。 © The Mc. Graw-Hill Companies, Inc. , 2006
圖P 19 © The Mc. Graw-Hill Companies, Inc. , 2006
圖P 24 © The Mc. Graw-Hill Companies, Inc. , 2006
圖P 25 © The Mc. Graw-Hill Companies, Inc. , 2006
圖P 29 © The Mc. Graw-Hill Companies, Inc. , 2006
圖P 30 © The Mc. Graw-Hill Companies, Inc. , 2006
圖P 31 © The Mc. Graw-Hill Companies, Inc. , 2006
圖P 32 © The Mc. Graw-Hill Companies, Inc. , 2006
- Slides: 67