MATLAB應用教程——編程方法、科學計算與系統模擬

徐奇偉

  • 出版商: 清華大學
  • 出版日期: 2024-12-01
  • 售價: $390
  • 貴賓價: 9.5$371
  • 語言: 簡體中文
  • ISBN: 7302678146
  • ISBN-13: 9787302678144
  • 相關分類: Matlab
  • 立即出貨 (庫存 < 3)

  • MATLAB應用教程——編程方法、科學計算與系統模擬-preview-1
  • MATLAB應用教程——編程方法、科學計算與系統模擬-preview-2
  • MATLAB應用教程——編程方法、科學計算與系統模擬-preview-3
MATLAB應用教程——編程方法、科學計算與系統模擬-preview-1

相關主題

商品描述

MATLAB 是適合多學科、多工作平臺的大型科學應用軟件。本書詳細講解MATLAB 的基本功能與操作,幫助讀者掌握利用MATLAB 解決實際問題的能力。全書詳細講解MATLAB 的基礎知識、數組、矩陣運算、符號運算、程序設計、二維繪圖、三維繪圖、函數運用、數據分析與優化求解、輸入與輸出等內容,同時還對 Simulink 系統模擬與應用進行詳細的講解。本書中的示例均已記錄在M 文件及其他相關文件中,讀者可以直接使用對應文件進行操作,以提高學習效率。本書內容翔實,結合示例引導,講解深入淺出,可作為高等院校理工科相關專業研究生、本科生的教材,也可作為廣大科研工程技術人員的參考用書。

目錄大綱

                                              

     

                                                                        目錄 

                                                                      CONTENTS 

     

     

     

第  1 章  初識   MATLAB....................................................................................................................1 

              22 分鐘 

    1.1   MATLAB 簡介........................................................................................................................1 

    1.2   工作界面 ..............................................................................................................................2 

        1.2.1   命令行窗口 .................................................................................................................3 

        1.2.2   命令歷史記錄窗口........................................................................................................7 

        1.2.3   當前文件夾 .................................................................................................................9 

        1.2.4   工作區和變量編輯器.....................................................................................................9 

    1.3   搜索路徑 ............................................................................................................................ 12 

        1.3.1   路徑搜索機制  ............................................................................................................ 12 

        1.3.2   設置搜索路徑  ............................................................................................................ 13 

    1.4   M 文件 ............................................................................................................................... 14 

        1.4.1   M 文件編輯器 ............................................................................................................ 14 

        1.4.2   函數式 M 文件 ........................................................................................................... 15 

        1.4.3   腳本式 M 文件 ........................................................................................................... 16 

        1.4.4   M 文件遵循的規則...................................................................................................... 17 

    1.5   通用命令 ............................................................................................................................ 18 

        1.5.1   常用命令................................................................................................................... 18 

        1.5.2   編輯命令................................................................................................................... 19 

        1.5.3   特殊符號................................................................................................................... 19 

        1.5.4   數據存取................................................................................................................... 20 

    1.6   幫助系統 ............................................................................................................................ 22 

        1.6.1   使用幫助命令  ............................................................................................................ 22 

        1.6.2   幫助導航................................................................................................................... 24 

        1.6.3   示例幫助................................................................................................................... 24 

    1.7   初步使用 MATLAB ............................................................................................................... 25 

    本章小結   ................................................................................................................................... 26 

    本章習題   ................................................................................................................................... 26 

第  2 章  基礎知識..........................................................................................................................29 

              30 分鐘 

    2.1   基本概念 ............................................................................................................................ 29 

        2.1.1   常量與變量 ............................................................................................................... 29 

        2.1.2   無窮量和非數值量...................................................................................................... 30 

        2.1.3   標量、向量、矩陣與數組      ............................................................................................ 31 

     4       MATLAB 應用教程——編程方法、科學計算與系統模擬 

              2.1.4   命令、函數、表達式和語句......................................................................................... 33 

          2.2   數據類型 ............................................................................................................................ 34 

              2.2.1   數據類型概述  ............................................................................................................ 34 

              2.2.2   整數型 ...................................................................................................................... 35 

              2.2.3   浮點數型................................................................................................................... 37 

              2.2.4   顯示格式................................................................................................................... 39 

              2.2.5   常用函數................................................................................................................... 39 

          2.3   基本運算 ............................................................................................................................ 40 

              2.3.1   算術運算................................................................................................................... 40 

              2.3.2   關系運算................................................................................................................... 42 

              2.3.3   邏輯運算................................................................................................................... 43 

              2.3.4   運算符優先級  ............................................................................................................ 46 

              2.3.5   常用函數................................................................................................................... 46 

          2.4   字符串 ............................................................................................................................... 47 

              2.4.1   字符串變量 ............................................................................................................... 47 

              2.4.2   一維字符數組  ............................................................................................................ 47 

              2.4.3   對字符串的操作   ......................................................................................................... 48 

              2.4.4   二維字符數組  ............................................................................................................ 50 

          本章小結   ................................................................................................................................... 52 

          本章習題   ................................................................................................................................... 52 

      第  3 章  數組.................................................................................................................................55 

                    38 分鐘 

          3.1   創建數組 ............................................................................................................................ 55 

              3.1.1   空數組 ...................................................................................................................... 55 

              3.1.2   一維數組(向量)...................................................................................................... 56 

              3.1.3   二維數組(矩陣)...................................................................................................... 58 

              3.1.4   多維數組................................................................................................................... 59 

              3.1.5   數組拼接................................................................................................................... 60 

              3.1.6   復數數組................................................................................................................... 61 

          3.2   創建標準數組...................................................................................................................... 62 

              3.2.1   0-1數組.................................................................................................................... 62 

              3.2.2   對角數組................................................................................................................... 63 

              3.2.3   隨機數組................................................................................................................... 65 

              3.2.4   幻方數組................................................................................................................... 66 

          3.3   數組屬性 ............................................................................................................................ 68 

              3.3.1   數組維度................................................................................................................... 68 

              3.3.2   數組大小................................................................................................................... 68 

              3.3.3   數組數據類型  ............................................................................................................ 70 

              3.3.4   測試函數................................................................................................................... 70 

          3.4   數組索引與尋址................................................................................................................... 71 

                                                                                      目    錄          5 

        3.4.1   元素存儲次序  ............................................................................................................ 71 

        3.4.2   元素的下標索引   ......................................................................................................... 72 

        3.4.3   數組元素賦值  ............................................................................................................ 74 

        3.4.4   抽取法創建數組   ......................................................................................................... 75 

    3.5   數組操作 ............................................................................................................................ 76 

        3.5.1   保存和裝載 ............................................................................................................... 77 

        3.5.2   擴展和裁剪 ............................................................................................................... 78 

        3.5.3   形狀改變................................................................................................................... 84 

        3.5.4   數組查找................................................................................................................... 87 

        3.5.5   數組排序................................................................................................................... 89 

        3.5.6   數組運算................................................................................................................... 90 

    本章小結   ................................................................................................................................... 91 

    本章習題   ................................................................................................................................... 91 

第  4 章  矩陣運算..........................................................................................................................94 

              40 分鐘 

    4.1   向量運算 ............................................................................................................................ 94 

        4.1.1   加減和數乘 ............................................................................................................... 94 

        4.1.2   點積和叉積 ............................................................................................................... 95 

    4.2   矩陣基本運算...................................................................................................................... 97 

        4.2.1   矩陣行列式的值   ......................................................................................................... 97 

        4.2.2   矩陣的秩................................................................................................................... 97 

        4.2.3   矩陣的逆與偽逆   ......................................................................................................... 98 

        4.2.4   矩陣算術運算  ............................................................................................................ 99 

        4.2.5   矩陣的乘冪 ..............................................................................................................102 

        4.2.6   矩陣運算函數  ...........................................................................................................103 

    4.3   矩陣特徵參數.....................................................................................................................105 

        4.3.1   範數 ........................................................................................................................105 

        4.3.2   條件數 .....................................................................................................................107 

        4.3.3   特徵值與特徵向量.....................................................................................................108 

    4.4   稀疏矩陣 ...........................................................................................................................111 

        4.4.1   稀疏矩陣存儲方式.....................................................................................................111 

        4.4.2   基本稀疏矩陣  ...........................................................................................................112 

        4.4.3   稀疏矩陣函數  ...........................................................................................................116 

    4.5   矩陣分解 ...........................................................................................................................118 

        4.5.1   Cholesky 分解............................................................................................................118 

        4.5.2   不完全 Cholesky 分解 .................................................................................................120 

        4.5.3   LU 分解 ...................................................................................................................121 

        4.5.4   不完全 LU 分解 .........................................................................................................122 

        4.5.5   QR 分解 ...................................................................................................................123 

        4.5.6   操作 QR 分解結果 .....................................................................................................124 

     6       MATLAB 應用教程——編程方法、科學計算與系統模擬 

              4.5.7   奇異值分解 ..............................................................................................................125 

          本章小結   ..................................................................................................................................126 

          本章習題   ..................................................................................................................................126 

      第  5 章  符號運算........................................................................................................................129 

                    23 分鐘 

          5.1   符號對象 ...........................................................................................................................129 

              5.1.1   符號對象聲明函數.....................................................................................................129 

              5.1.2   符號表達式與符號方程     ..............................................................................................133 

              5.1.3   符號函數..................................................................................................................134 

              5.1.4   符號矩陣..................................................................................................................134 

              5.1.5   自變量函數 ..............................................................................................................136 

          5.2   符號運算函數.....................................................................................................................137 

              5.2.1   符號變量代換  ...........................................................................................................137 

              5.2.2   符號對象轉換為數值對象      ...........................................................................................138 

              5.2.3   符號表達式化簡   ........................................................................................................139 

              5.2.4   特定符號運算  ...........................................................................................................145 

              5.2.5   其他符號運算  ...........................................................................................................146 

          5.3   符號矩陣 ...........................................................................................................................147 

              5.3.1   元素訪問..................................................................................................................147 

              5.3.2   加減運算..................................................................................................................148 

              5.3.3   乘法運算..................................................................................................................149 

              5.3.4   除法運算..................................................................................................................150 

              5.3.5   乘方運算..................................................................................................................151 

              5.3.6   指數運算..................................................................................................................151 

          5.4   符號方程求解.....................................................................................................................151 

              5.4.1   代數方程求解  ...........................................................................................................152 

              5.4.2   微分方程求解  ...........................................................................................................154 

          本章小結   ..................................................................................................................................157 

          本章習題   ..................................................................................................................................157 

      第  6 章  程序設計........................................................................................................................160 

                    21 分鐘 

          6.1   程序語法規則.....................................................................................................................160 

              6.1.1   程序設計中的變量.....................................................................................................160 

              6.1.2   編程方法..................................................................................................................161 

          6.2   程序結構 ...........................................................................................................................161 

              6.2.1   順序結構..................................................................................................................162 

              6.2.2   循環結構..................................................................................................................162 

              6.2.3   條件結構..................................................................................................................167 

          6.3   控制語句 ...........................................................................................................................170 

              6.3.1   continue 語句.............................................................................................................170 

                                                                                      目    錄          7 

        6.3.2   break 語句 ................................................................................................................171 

        6.3.3   keyboard 語句............................................................................................................172 

        6.3.4   return 語句................................................................................................................173 

        6.3.5   input 函數.................................................................................................................174 

    6.4   程序調試 ...........................................................................................................................174 

        6.4.1   常見的錯誤類型   ........................................................................................................175 

        6.4.2   直接調試法 ..............................................................................................................175 

        6.4.3   工具調試法 ..............................................................................................................176 

        6.4.4   程序調試命令  ...........................................................................................................177 

        6.4.5   程序調試剖析  ...........................................................................................................178 

    本章小結   ..................................................................................................................................181 

    本章習題   ..................................................................................................................................181 

第  7 章  二維繪圖........................................................................................................................184 

              13 分鐘 

    7.1   數據可視化  ........................................................................................................................184 

        7.1.1   劃分子圖..................................................................................................................184 

        7.1.2   離散數據可視化   ........................................................................................................186 

        7.1.3   連續函數可視化   ........................................................................................................188 

    7.2   二維圖形繪制.....................................................................................................................189 

        7.2.1   二維圖形繪制步驟.....................................................................................................189 

        7.2.2   基本繪圖函數  ...........................................................................................................190 

        7.2.3   繪制函數圖 ..............................................................................................................193 

        7.2.4   特殊坐標圖 ..............................................................................................................197 

        7.2.5   專用繪圖函數  ...........................................................................................................201 

    7.3   圖形的修飾  ........................................................................................................................207 

        7.3.1   色彩、線型和點型.....................................................................................................207 

        7.3.2   坐標軸的調整  ...........................................................................................................208 

        7.3.3   刻度和柵格 ..............................................................................................................210 

        7.3.4   設置坐標框 ..............................................................................................................211 

        7.3.5   圖形標識與註釋   ........................................................................................................212 

        7.3.6   圖案填充..................................................................................................................215 

    本章小結   ..................................................................................................................................217 

    本章習題   ..................................................................................................................................218 

第  8 章  三維繪圖........................................................................................................................222 

              11 分鐘 

    8.1   三維圖形繪制.....................................................................................................................222 

        8.1.1   基本繪圖步驟  ...........................................................................................................222 

        8.1.2   基本繪圖函數  ...........................................................................................................223 

        8.1.3   圖形的修飾 ..............................................................................................................226 

    8.2   網格與曲面圖.....................................................................................................................226 

     8       MATLAB 應用教程——編程方法、科學計算與系統模擬 

              8.2.1   生成柵格數據  ...........................................................................................................226 

              8.2.2   數據生成函數  ...........................................................................................................228 

              8.2.3   繪制網格圖 ..............................................................................................................229 

              8.2.4   繪制曲面圖 ..............................................................................................................231 

              8.2.5   繪制函數圖 ..............................................................................................................232 

          8.3   專用繪圖函數.....................................................................................................................234 

              8.3.1   序列圖 .....................................................................................................................234 

              8.3.2   條形圖 .....................................................................................................................235 

              8.3.3   餅圖 ........................................................................................................................236 

              8.3.4   等高線圖..................................................................................................................236 

          本章小結   ..................................................................................................................................237 

          本章習題   ..................................................................................................................................238 

      第  9 章  函數運用........................................................................................................................240 

                    15 分鐘 

          9.1   函數文件 ...........................................................................................................................240 

              9.1.1   函數文件結構  ...........................................................................................................240 

              9.1.2   函數調用..................................................................................................................243 

          9.2   函數類型 ...........................................................................................................................245 

              9.2.1   匿名函數..................................................................................................................245 

              9.2.2   主函數 .....................................................................................................................246 

              9.2.3   嵌套函數..................................................................................................................246 

              9.2.4   子函數 .....................................................................................................................247 

              9.2.5   私有函數..................................................................................................................247 

              9.2.6   重載函數..................................................................................................................247 

          9.3   參數傳遞 ...........................................................................................................................248 

              9.3.1   參數傳遞概述  ...........................................................................................................248 

              9.3.2   輸入和輸出參數的數目     ..............................................................................................248 

              9.3.3   可變數目的參數傳遞..................................................................................................249 

              9.3.4   返回被修改的輸入參數     ..............................................................................................250 

              9.3.5   全局變量..................................................................................................................251 

          本章小結   ..................................................................................................................................251 

          本章習題   ..................................................................................................................................252 

      第  10 章   Simulink 系統模擬   .......................................................................................................254 

                    16 分鐘 

          10.1   基本介紹..........................................................................................................................254 

              10.1.1   運行 Simulink ..........................................................................................................254 

              10.1.2   初識模塊庫.............................................................................................................255 

              10.1.3   打開系統模型..........................................................................................................256 

              10.1.4   保存系統模型..........................................................................................................256 

              10.1.5   打印模型框圖並生成報告..........................................................................................256 

                                                                                      目    錄          9 

        10.1.6   常用鼠標和鍵盤操作    ................................................................................................257 

        10.1.7   環境設置 ................................................................................................................258 

        10.1.8   模擬基本步驟..........................................................................................................259 

        10.1.9   系統封裝 ................................................................................................................261 

    10.2   模塊庫介紹  ......................................................................................................................262 

        10.2.1   信號源模塊庫..........................................................................................................262 

        10.2.2   信號輸出模塊庫   ......................................................................................................263 

        10.2.3   表格模塊庫.............................................................................................................264 

        10.2.4   數學運算模塊庫   ......................................................................................................265 

        10.2.5   連續模塊庫.............................................................................................................266 

        10.2.6   非線性模塊庫..........................................................................................................268 

        10.2.7   離散模塊庫.............................................................................................................269 

        10.2.8   信號路由模塊庫   ......................................................................................................270 

    10.3   模塊操作..........................................................................................................................271 

        10.3.1   Simulink 模塊類型 ....................................................................................................271 

        10.3.2   模塊的創建.............................................................................................................272 

        10.3.3   模塊的連接.............................................................................................................273 

        10.3.4   模塊參數設置..........................................................................................................276 

    10.4   系統模擬..........................................................................................................................276 

        10.4.1   設置模擬參數..........................................................................................................277 

        10.4.2   啟動模擬 ................................................................................................................278 

        10.4.3   模擬結果分析..........................................................................................................278 

        10.4.4   簡單系統的模擬分析    ................................................................................................279 

    本章小結   ..................................................................................................................................283 

    本章習題   ..................................................................................................................................283 

第  11 章  數據分析與優化求解....................................................................................................286 

              21 分鐘 

    11.1   多項式計算  ......................................................................................................................286 

        11.1.1   四則運算 ................................................................................................................286 

        11.1.2   多項式導函數..........................................................................................................287 

        11.1.3   多項式導函數求值   ...................................................................................................288 

    11.2   數據插值..........................................................................................................................289 

        11.2.1   一維插值 ................................................................................................................289 

        11.2.2   二維插值 ................................................................................................................291 

        11.2.3   三維插值 ................................................................................................................293 

        11.2.4   多維插值 ................................................................................................................294 

        11.2.5   樣條插值 ................................................................................................................295 

    11.3   曲線擬合..........................................................................................................................296 

        11.3.1   多項式擬合.............................................................................................................296 

        11.3.2   曲線擬合工具..........................................................................................................297 

     10       MATLAB 應用教程——編程方法、科學計算與系統模擬 

           11.4   優化問題..........................................................................................................................300 

               11.4.1   創建優化變量..........................................................................................................301 

               11.4.2   創建方程問題..........................................................................................................301 

               11.4.3   創建優化問題..........................................................................................................302 

               11.4.4   問題求解 ................................................................................................................304 

           本章小結   ..................................................................................................................................309 

           本章習題   ..................................................................................................................................309 

       第  12 章  輸入與輸出     ..................................................................................................................313 

                     17 分鐘 

           12.1   文件打開與關閉   ................................................................................................................313 

               12.1.1   打開文件 ................................................................................................................313 

               12.1.2   關閉文件 ................................................................................................................314 

           12.2   文件讀寫..........................................................................................................................315 

               12.2.1   讀取二進制文件   ......................................................................................................315 

               12.2.2   寫入二進制文件   ......................................................................................................317 

               12.2.3   寫入文本文件..........................................................................................................318 

               12.2.4   讀取文本文件..........................................................................................................319 

               12.2.5   文件格式化與二進制輸入/輸出       ..................................................................................321 

           12.3   文件位置控制  ...................................................................................................................323 

               12.3.1   檢測函數 ................................................................................................................323 

               12.3.2   錯誤提示 ................................................................................................................324 

               12.3.3   判斷數據位置..........................................................................................................325 

               12.3.4   指針位置設定..........................................................................................................325 

           本章小結   ..................................................................................................................................326 

           本章習題   ..................................................................................................................................326 

       參考文獻     ......................................................................................................................................330