![matlab programming-1-1_第1頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-3/22/0785a6b3-cf85-4db7-91a7-cb8132461343/0785a6b3-cf85-4db7-91a7-cb81324613431.gif)
![matlab programming-1-1_第2頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-3/22/0785a6b3-cf85-4db7-91a7-cb8132461343/0785a6b3-cf85-4db7-91a7-cb81324613432.gif)
![matlab programming-1-1_第3頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-3/22/0785a6b3-cf85-4db7-91a7-cb8132461343/0785a6b3-cf85-4db7-91a7-cb81324613433.gif)
![matlab programming-1-1_第4頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-3/22/0785a6b3-cf85-4db7-91a7-cb8132461343/0785a6b3-cf85-4db7-91a7-cb81324613434.gif)
![matlab programming-1-1_第5頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-3/22/0785a6b3-cf85-4db7-91a7-cb8132461343/0785a6b3-cf85-4db7-91a7-cb81324613435.gif)
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、Control System Simulation and CAD(Matlab language)Suzhen Wang課程介紹課程介紹雙語(yǔ)教學(xué)目標(biāo): (1)掌握控制系統(tǒng)仿真的基本方法。 (2)掌握計(jì)算機(jī)仿真語(yǔ)言MATLAB的使用及程序設(shè)計(jì)方法,并能將其與相關(guān)專(zhuān)業(yè)課程相結(jié)合,進(jìn)行系統(tǒng)建模、仿真和科學(xué)研究等。 (3) 培養(yǎng)與提高學(xué)習(xí)英文專(zhuān)業(yè)課程的能力。Matlab 編程語(yǔ)言的特點(diǎn): 可以不必具備其它語(yǔ)言的基礎(chǔ),語(yǔ)法簡(jiǎn)單,上手容易,但函數(shù)繁多。課程安排課程安排J學(xué)時(shí): 32學(xué)時(shí)J安排:授課20學(xué)時(shí),上機(jī)12學(xué)時(shí)。J考核方式:平時(shí)成績(jī)占10%,實(shí)驗(yàn)成績(jī)占20%,期末成績(jī)占70%。J期末考試形式待定
2、。教材教材 CONTROL SYSTEM SIMULATION AND CAD Thanks to OUYANG Xinyu and XU Shaochuan要求打印教材與實(shí)驗(yàn)指導(dǎo)書(shū)參考教材參考教材1.MATLAB Programming(Fourth Edition), Stephen J.Chapman著 , 科學(xué)出版社2.控制系統(tǒng)仿真與計(jì)算機(jī)輔助設(shè)計(jì)(第二版),薛定宇 著,機(jī)械工業(yè)出版社3.自動(dòng)控制原理(第五版),胡壽松 主編,科學(xué)出版社4.Modern Control Systems (Eleven Edition), Richard C. Dorf & Robert H. B
3、ishop 著,電子工業(yè)出版社(中英文版均有,建議讀英文版)5.MATLAB 幫助文檔幫助文檔6.Control System ToolboxGetting Started Guide -R2013a(電子版)(電子版)http:/ 中文論壇學(xué)習(xí)方法學(xué)習(xí)方法J溫故而知新J實(shí)踐出真知J擴(kuò)展知識(shí)面J舉一而反三前言前言 控制系統(tǒng)仿真基本概念控制系統(tǒng)仿真基本概念 控制系統(tǒng)的計(jì)算機(jī)仿真控制系統(tǒng)的計(jì)算機(jī)仿真是一門(mén)涉及到控制理論、計(jì)算數(shù)是一門(mén)涉及到控制理論、計(jì)算數(shù)學(xué)與計(jì)算機(jī)技術(shù)的綜合性新型學(xué)科。學(xué)與計(jì)算機(jī)技術(shù)的綜合性新型學(xué)科。 這門(mén)學(xué)科的產(chǎn)生及發(fā)展差不多是與計(jì)算機(jī)的發(fā)明及發(fā)展這門(mén)學(xué)科的產(chǎn)生及發(fā)展差不多是與計(jì)
4、算機(jī)的發(fā)明及發(fā)展同步進(jìn)行的。同步進(jìn)行的。 它包含控制系統(tǒng)分析、綜合、設(shè)計(jì)、檢驗(yàn)等多方面的計(jì)它包含控制系統(tǒng)分析、綜合、設(shè)計(jì)、檢驗(yàn)等多方面的計(jì)算機(jī)處理。算機(jī)處理。 計(jì)算機(jī)仿真基于計(jì)算機(jī)的高速而精確的運(yùn)算,以實(shí)現(xiàn)各計(jì)算機(jī)仿真基于計(jì)算機(jī)的高速而精確的運(yùn)算,以實(shí)現(xiàn)各種功能。種功能。 系統(tǒng)仿真系統(tǒng)仿真中的基本中的基本概念概念 系統(tǒng)系統(tǒng):系統(tǒng)是物質(zhì)世界中相互制約又相互聯(lián)系著的、以期實(shí)現(xiàn)某:系統(tǒng)是物質(zhì)世界中相互制約又相互聯(lián)系著的、以期實(shí)現(xiàn)某種目的的一個(gè)運(yùn)動(dòng)整體,這個(gè)整體叫做系統(tǒng)。種目的的一個(gè)運(yùn)動(dòng)整體,這個(gè)整體叫做系統(tǒng)。 “ “系統(tǒng)系統(tǒng)”是一個(gè)很大的概念,通常研究的系統(tǒng)有工程系統(tǒng)和非工是一個(gè)很大的概念,通常研究
5、的系統(tǒng)有工程系統(tǒng)和非工程系統(tǒng)。程系統(tǒng)。 工程系統(tǒng)有:電力拖動(dòng)自動(dòng)控制系統(tǒng)、機(jī)械系統(tǒng)、水力、冶金、工程系統(tǒng)有:電力拖動(dòng)自動(dòng)控制系統(tǒng)、機(jī)械系統(tǒng)、水力、冶金、化工、熱力學(xué)系統(tǒng)等?;?、熱力學(xué)系統(tǒng)等。 非工程系統(tǒng):宇宙、自然界、人類(lèi)社會(huì)、經(jīng)濟(jì)系統(tǒng)、交通系統(tǒng)、非工程系統(tǒng):宇宙、自然界、人類(lèi)社會(huì)、經(jīng)濟(jì)系統(tǒng)、交通系統(tǒng)、管理系統(tǒng)、生態(tài)系統(tǒng)、人口系統(tǒng)等。管理系統(tǒng)、生態(tài)系統(tǒng)、人口系統(tǒng)等。 模型模型:模型是對(duì)所要研究的系統(tǒng)在某些特定方面的抽象。通過(guò)模:模型是對(duì)所要研究的系統(tǒng)在某些特定方面的抽象。通過(guò)模型對(duì)原型系統(tǒng)進(jìn)行研究,將具有更深刻、更集中的特點(diǎn)型對(duì)原型系統(tǒng)進(jìn)行研究,將具有更深刻、更集中的特點(diǎn)。 系系統(tǒng)仿真統(tǒng)仿真
6、:就是以系統(tǒng)數(shù)學(xué)模型為基礎(chǔ),以計(jì)算機(jī)為工:就是以系統(tǒng)數(shù)學(xué)模型為基礎(chǔ),以計(jì)算機(jī)為工具對(duì)系統(tǒng)進(jìn)行實(shí)驗(yàn)研究的一種方法具對(duì)系統(tǒng)進(jìn)行實(shí)驗(yàn)研究的一種方法。 要對(duì)系統(tǒng)進(jìn)行研究,首先要建立系統(tǒng)的數(shù)學(xué)模型。對(duì)于一個(gè)簡(jiǎn)單的要對(duì)系統(tǒng)進(jìn)行研究,首先要建立系統(tǒng)的數(shù)學(xué)模型。對(duì)于一個(gè)簡(jiǎn)單的數(shù)學(xué)模型,可以采用分析法或數(shù)學(xué)解析法進(jìn)行研究,但對(duì)于復(fù)雜的系統(tǒng),數(shù)學(xué)模型,可以采用分析法或數(shù)學(xué)解析法進(jìn)行研究,但對(duì)于復(fù)雜的系統(tǒng),則需要借助于仿真的方法來(lái)研究。則需要借助于仿真的方法來(lái)研究。 計(jì)計(jì)算機(jī)仿真三要素算機(jī)仿真三要素:系統(tǒng)、模型與計(jì)算機(jī)。它們之間的關(guān)系:系統(tǒng)、模型與計(jì)算機(jī)。它們之間的關(guān)系如下:如下: 仿真實(shí)驗(yàn)仿真實(shí)驗(yàn)數(shù)學(xué)模型建立數(shù)學(xué)
7、模型建立仿真模型建立仿真模型建立系統(tǒng)系統(tǒng)模型模型計(jì)算機(jī)計(jì)算機(jī) 數(shù)學(xué)模型建立數(shù)學(xué)模型建立:實(shí)際上是一個(gè)模型辯識(shí)的過(guò)程。所建模型常常是忽略:實(shí)際上是一個(gè)模型辯識(shí)的過(guò)程。所建模型常常是忽略了一些次要因素的簡(jiǎn)化模型。了一些次要因素的簡(jiǎn)化模型。 仿真模型建立仿真模型建立:即是設(shè)計(jì)一種算法,以使系統(tǒng)模型能被計(jì)算機(jī)接受并:即是設(shè)計(jì)一種算法,以使系統(tǒng)模型能被計(jì)算機(jī)接受并能在計(jì)算機(jī)上運(yùn)行。顯然,由于在算法設(shè)計(jì)上存在著誤差,所以仿真模型能在計(jì)算機(jī)上運(yùn)行。顯然,由于在算法設(shè)計(jì)上存在著誤差,所以仿真模型對(duì)于實(shí)際系統(tǒng)將是一個(gè)二次簡(jiǎn)化模型對(duì)于實(shí)際系統(tǒng)將是一個(gè)二次簡(jiǎn)化模型。(傳遞函數(shù)(傳遞函數(shù)Z Z變換,微分方程前向后向離
8、散化等)變換,微分方程前向后向離散化等) 仿真實(shí)驗(yàn)仿真實(shí)驗(yàn):即是對(duì)模型的運(yùn)算。需要設(shè)計(jì)一個(gè)合理的、服務(wù)于系統(tǒng)研:即是對(duì)模型的運(yùn)算。需要設(shè)計(jì)一個(gè)合理的、服務(wù)于系統(tǒng)研究的仿真軟件。究的仿真軟件。 系統(tǒng)仿真技術(shù)實(shí)質(zhì)上就是建立仿真模型并進(jìn)行仿真實(shí)驗(yàn)的技術(shù)。系統(tǒng)仿真技術(shù)實(shí)質(zhì)上就是建立仿真模型并進(jìn)行仿真實(shí)驗(yàn)的技術(shù)。 系統(tǒng)仿真的基本過(guò)程:系統(tǒng)仿真的基本過(guò)程: (1 1)建立系統(tǒng)的數(shù)學(xué)模型;)建立系統(tǒng)的數(shù)學(xué)模型; (2 2)轉(zhuǎn)換成仿真模型;)轉(zhuǎn)換成仿真模型; (3 3)編寫(xiě)仿真程序;)編寫(xiě)仿真程序; (4 4)對(duì)仿真模型進(jìn)行修改校驗(yàn),看與實(shí)際系統(tǒng)是否一致,)對(duì)仿真模型進(jìn)行修改校驗(yàn),看與實(shí)際系統(tǒng)是否一致, 確認(rèn)
9、模型的正確性;確認(rèn)模型的正確性; (5 5)運(yùn)行仿真程序,在不同的初始條件和參數(shù)下,對(duì)系統(tǒng))運(yùn)行仿真程序,在不同的初始條件和參數(shù)下,對(duì)系統(tǒng) 進(jìn)行反復(fù)分析和研究。進(jìn)行反復(fù)分析和研究。 控制控制系系統(tǒng)仿真的基本過(guò)程:統(tǒng)仿真的基本過(guò)程:1.1. 建立被控對(duì)象的建立被控對(duì)象的數(shù)學(xué)模型數(shù)學(xué)模型;( (傳遞函數(shù),微分方程,狀態(tài)空間表達(dá)式等)傳遞函數(shù),微分方程,狀態(tài)空間表達(dá)式等)2.2. 轉(zhuǎn)轉(zhuǎn)換成仿真模型換成仿真模型;3.3. 編編寫(xiě)仿真程序;寫(xiě)仿真程序;4.4. 對(duì)被控對(duì)象模對(duì)被控對(duì)象模型進(jìn)行修改校驗(yàn),看與實(shí)際系統(tǒng)是否一致型進(jìn)行修改校驗(yàn),看與實(shí)際系統(tǒng)是否一致, 確確認(rèn)模型的正確性認(rèn)模型的正確性;5.5.
10、在計(jì)算機(jī)輔助下,設(shè)計(jì)控制器在計(jì)算機(jī)輔助下,設(shè)計(jì)控制器(比如(比如PIDPID控制器等,校正,帶有觀測(cè)控制器等,校正,帶有觀測(cè)器的狀態(tài)反饋控制器,自適應(yīng)控制,智能控制等,可看做是串聯(lián)在被控對(duì)象之前的一器的狀態(tài)反饋控制器,自適應(yīng)控制,智能控制等,可看做是串聯(lián)在被控對(duì)象之前的一個(gè)數(shù)學(xué)模型)個(gè)數(shù)學(xué)模型);6.6. 運(yùn)行控制系統(tǒng)仿運(yùn)行控制系統(tǒng)仿真程序,在不同的初始條真程序,在不同的初始條件、參數(shù)、不件、參數(shù)、不同外界輸入作用或者擾動(dòng)下同外界輸入作用或者擾動(dòng)下,對(duì)系,對(duì)系統(tǒng)進(jìn)統(tǒng)進(jìn)行反復(fù)分析和研行反復(fù)分析和研究究(跟蹤參考輸入如階躍響應(yīng),(跟蹤參考輸入如階躍響應(yīng),BODEBODE圖,根軌跡圖等等,以考察控制
11、器的性能)圖,根軌跡圖等等,以考察控制器的性能);7.7. 將調(diào)試好的控制器應(yīng)用到實(shí)際系統(tǒng)中。將調(diào)試好的控制器應(yīng)用到實(shí)際系統(tǒng)中。Matlab作為美國(guó) MathWorks公司開(kāi)發(fā)的用于概念設(shè)計(jì),算法開(kāi)發(fā),建模仿真,實(shí)時(shí)實(shí)現(xiàn)的理想的集成環(huán)境。是目前最好的科學(xué)計(jì)算類(lèi)軟件。作為和Mathematica、Maple并列的三大數(shù)學(xué)軟件。其強(qiáng)項(xiàng)就是其強(qiáng)大的矩陣計(jì)算以及仿真能力。要知道Matlab的由來(lái)就是Matrix + Laboratory = Matlab,所以這個(gè)軟件在國(guó)內(nèi)也被稱作矩陣實(shí)驗(yàn)室。每次MathWorks發(fā)布Matlab的同時(shí)也會(huì)發(fā)布仿真工具Simulink。在歐美很多大公司在將產(chǎn)品投入實(shí)際
12、使用之前都會(huì)進(jìn)行仿真試驗(yàn),他們所主要使用的仿真軟件就是Simulink。Matlab提供了自己的編譯器:全面兼容C以及Fortran兩大語(yǔ)言。所以所以Matlab是工程師,科研工作者手上最好的語(yǔ)言,最好的工具和環(huán)境。是工程師,科研工作者手上最好的語(yǔ)言,最好的工具和環(huán)境。MATLAB簡(jiǎn)介實(shí)驗(yàn)六 控制系統(tǒng)PID 校正器設(shè)計(jì)法 Simulink 根軌跡與bode圖Contents of this bookChapter 1 Introduction to MATLABChapter 2 Basic MATLAB CommandsChapter 3 Programming in MATLABChapt
13、er 4 Basic Plotting FunctionChapter 5 Application of MATLAB in Control System SimulationChapter 6 Simulink-Interactive and Integration EnvironmentChapter 7 Application of Automation Control System SimulationExperimentsChapter1 Introduction to MATLAB The Main Contents:The MATLAB Characteristics The M
14、ATLAB Environment Summary 1.1 The MATLAB Characteristics 1. The Advantages of MATLAB for Technical Programming MATLAB has many advantages compared to conventional computer languages for technical problem solving. Among them are: (1) Ease of Use (2) Platform Independence (3) Predefined Functions (預(yù)定義
15、函數(shù)) (4) Device-Independent Plotting (5) Graphical User Interface (圖形用戶界面) (6) MATLAB Compiler (1) Ease of UseMATLAB is an interpreted language, like many versions of Basic. Like Basic, it is very easy to use. Programs may be easily written, modified and debugged. Many program development tools are p
16、rovided to make the program easy to use.(2) Platform Independence MATLAB is supported on many different computer systems (Windows9x/NT/2000/XP/ UNIX), providing a large measure of platform independence.(3) Predefined Functions (預(yù)定義函數(shù))MATLAB comes complete with an extensive library of predefined func
17、tions that provide tested and prepackaged solutions to many basic technical tasks.In addition to the large library of functions built into the basic MATLAB language, many specific-purpose toolboxes are available to help solve complex problems in specific areas.(4) Device-Independent Plotting Unlike
18、other computer languages, MATLAB has many integral plotting and imaging commands. The plots and images can be displayed on any graphical output device supported by the computer on which MATLAB is running. This capability makes MATLAB an outstanding tool for visualizing technical data.(5) Graphical U
19、ser Interface (圖形用戶界面)MATLAB includes tools that allow a programmer to interactively construct a graphical user interface (GUI) for his or her program. With this capability, the programmer can design sophisticated data analysis programs that can be operated by relatively inexperienced users.(6) MATL
20、AB Compiler A separate MATLAB compiler is available. This compiler can compile a MATLAB program into a true executable program that runs faster than the interpreted code. It is a great way to convert a prototype MATLAB program into an executable program suitable for sale and distribution to users.2.
21、 Disadvantages of MATLAB MATLAB is an interpreted(解釋?zhuān)?language, and therefore can execute more slowly than compiled(編譯) languages. This problem can be mitigated(解決) by properly structuring the MATLAB program and by the use of the MATLAB compiler to compile the final MATLAB program before distributio
22、n(發(fā)行) and general use. Expensive!編譯后的文件擴(kuò)展名為mex,它可以在計(jì)算機(jī)中直接執(zhí)行,速度比M文件快。計(jì)算機(jī)不能直接理解高級(jí)語(yǔ)言,只能直接理解機(jī)器語(yǔ)言,所以必須要把高級(jí)語(yǔ)言翻譯成機(jī)器語(yǔ)言,計(jì)算機(jī)才能執(zhí)行高級(jí)語(yǔ)言編寫(xiě)的程序.翻譯的方式有兩種:一個(gè)是編譯,一個(gè)是解釋。編譯型語(yǔ)言寫(xiě)的程序執(zhí)行之前,需要一個(gè)專(zhuān)門(mén)的編譯過(guò)程,把程序編譯成為機(jī)器語(yǔ)言的文件,以后要運(yùn)行的話就不用重復(fù)翻譯了,直接使用編譯的結(jié)果就行了。程序執(zhí)行效率高,依賴編譯器,跨平臺(tái)性差些。如C、C+、Delphi等。解釋型語(yǔ)言在運(yùn)行程序的時(shí)候才翻譯,專(zhuān)門(mén)有一個(gè)解釋器去進(jìn)行翻譯,每個(gè)語(yǔ)句都是執(zhí)行的時(shí)候才翻譯。
23、效率比較低,依賴解釋器,跨平臺(tái)性好,如Basic。1.2 The MATLAB Environment The MATLAB development environment is a set of tools to help you use MATLAB functions and files. The three most important types of windows are Command Windows, Figure Windows and Edit/Debug Windows. In addition, MATLAB can display other windows tha
24、t provide help and that allow the user to examine the values of variables defined in memory.The MATLAB development environment is a set of tools to help you use MATLAB functions and files. Many of these tools are graphical user interfaces. The fundamental unit of data in any MATLAB program is the ar
25、ray. An array is a collection of data values organized into rows and columns, and known by single name.Individual data values within an array may be accessed by including the name of thearray followed by subscripts in parentheses that identify the row and column of theparticular value. Even scalars
26、are treated as arrays by MATLAB, they are simply arrays with only one row and one column. We will learn how to create and manipulate MATLAB arrays in Chapter 2.擴(kuò)展1. The MATLAB Desktop The first time MATLAB starts, the desktop appears as shown in the following illustration(插圖). Start Button and Launc
27、h Pad(啟動(dòng)平臺(tái)) Run tools and access documentation for all of your MathWorks products. Command Window (命令窗口)Run MATLAB functions. Command History Window (命令歷史窗口)View a log(日志) of the functions you entered in the Command Window, copy them, and execute them. Help Browser(幫助瀏覽器) View and search the documen
28、tation for the full family of MATLAB products. Current Directory Browser(當(dāng)前路徑窗口) View MATLAB files and related files, perform file operations such as open, and find content. Workspace Browser(工作空間瀏覽器) View and make changes to the contents of the workspace. Array Editor(陣列編輯器) View array contents in
29、a table format(表格格式) and edit the values. Editor/Debugger(編輯器/調(diào)試器) Create, edit, and debug M-files (files containing MATLAB functions).2. The Command Window The right hand side of the MATLAB desktop contains the Command Window. Users can enter interactive(交互式) commands at the command prompt (提示) in
30、the Command Window, and they will be executed on the spot(當(dāng)場(chǎng)).Scratch pad 演草紙有時(shí)稱為數(shù)學(xué)演算紙,即時(shí)可看到結(jié)果。(1) The Format Command The format(格式) command controls the numeric format of the values displayed by MATLAB. The command affects only how numbers are displayed, not how MATLAB computes or saves them. x = 4
31、/3 1.2345e-6 format short x=1.3333 0.0000 format short e x=1.3333e+000 1.2345e-006 format long x=1.33333333333333 0.00000123450000 format long e x=1.333333333333333e+000 1.234500000000000e-006 x = 4/3 1.2345e-6x = 1.3333 0.0000 format short xx = 1.3333 0.0000 format short e xx = 1.3333e+000 1.2345e-
32、006 format long xx = 1.33333333333333 0.00000123450000(2) Suppressing(禁止)(禁止) Output If you simply type a statement(語(yǔ)句) and press Return or Enter, MATLAB automatically displays the results on screen. However, if you end the line with a semicolon(;), MATLAB performs the computation but does not displ
33、ay any output. For example, a=magic(4); b=magic(3) ans = 8.00 1.00 6.00 3.00 5.00 7.00 4.00 9.00 2.00 加分號(hào)和不加分號(hào)時(shí)語(yǔ)句都執(zhí)行了,只是是否顯示結(jié)果的區(qū)別。 (3) Command Line Editing Various arrow(箭頭) and control keys(控制鍵) on your keyboard allow you to recall(回顧), edit, and reuse commands you have typed earlier. The list of a
34、vailable command line editing keys is different on different computers. Experiment to see which of the following keys is available on your machine. 3. The Command History Window (1) Viewing Statements in the Command History Window ; (2) Deleting Entries(條目) in the Command History Window. 4. The Edit
35、/Debug Window An Edit/Debug Window is used to create M-files(M文件), or to modify existing ones. An Edit/Debug Window is created automatically when you create a new M-file or open an existing one. You can create a new M-file with the “File/New/M-file” selection from the desktop menu, or by clicking th
36、e Toolbar icon. You can open an existing M-file with the “File/Open” selection from the desktop menu or by clicking the Toolbar icon(工具欄圖標(biāo)). Instead of typing commands directly in the Command Window, a series of commands may be placed into a file, and the entire file may be executed by typing its na
37、me in the Command Window. Such files are called script files. Script files (and functions, which we will see later) are also known as M-files because the have a file extension of “.m”.5. Figure Windows(圖形窗口)(圖形窗口) MATLAB directs graphics output to a window that is separate from the Command Window. I
38、n MATLAB, this window is referred to as a figure. Graphics(制圖) functions automatically create new figure windows if none currently exist. If a figure window already exists, MATLAB uses that window. If multiple figure windows exist, one is designated(指定) as the current figure and is used by MATLAB (t
39、his is generally the last figure used or the last figure you clicked the mouse in). The figure function creates figure windows. For example, t = 0:pi/100:2*pi; y = sin(t); plot(t,y) After creating a plot, you can make changes to it and annotate(注釋?zhuān)?it with the Plot Editor, which is an easy-to-use gr
40、aphical interface. t = 0:pi/50:10*pi;plot3(sin(t),cos(t),t)axis square; grid on6. The MATLAB Workspace(工作空間)(工作空間) The MATLAB workspace contains a set of variables (named arrays) that you can manipulate(操作) from the MATLAB command line. You can use the who and whos commands to see what is currently
41、in the workspace. The who command gives a short list, while the whos command also gives size and data type information. Here is the output produced by whos on a workspace containing three variables of different data types. whos Name Size Bytes Class A 2x4 64 double array B 2x4 64 double array C 2x4
42、64 double array Grand total is 24 elements using 192 bytes (1) Opening the Workspace Browser To open the Workspace browser, select Workspace from the View menu in the MATLAB desktop, or type workspace at the Command Window prompt. The Workspace browser opens. (2) Viewing the Current Workspace The Wo
43、rkspace browser shows the name of each variable, its array size, its size in bytes, and the class. (3) Loading and Saving the Workspace MATLABs save(保存) and load (加載)commands let you save the contents of the MATLAB workspace at any time during a session and then reload the data back into MATLAB duri
44、ng that session or a later one. Load and save can also import and export text data files. For example, save june10 saves the entire workspace contents in the file june10.mat. If desired, you can save only certain variables by specifying the variable names after the filename. For example, save june10
45、 x y z saves only variables x, y, and z. load june10 x y7. Getting Help You can get help in MATLAB in three ways. The preferred method is to use the help Browser. You can start the Help Browser by selecting the Help icon from the desktop toolbar, or by typing helpdesk or helpwin in the Command Windo
46、w. There are also two command-line oriented ways to get help. The first way is to type help or help followed by a function name in the Command Window. lookfor(查找有類(lèi)似單詞的) 8. A Few Important Commands If you are new to MATLAB, a few demonstrations(示范或演示) may help to give you a feel for(摸索) its capabilit
47、ies(性能). To run MATLABs built-in (內(nèi)置)demonstrations, type demo in the command Window.9. The MATLAB Path Manager (1) Purpose of the Search Path MATLAB uses a search path to find M-files and other MATLAB related files, which are organized in directories(目錄) on your file system. Any file you want to ru
48、n in MATLAB must reside in a directory that is on the search path or in the current directory. By default, the files supplied with MATLAB and MathWorks toolboxes are included in the search path. If you create any MATLAB related files, add the directories containing the files to the MATLAB search pat
49、h.(2) Viewing and Setting the Search Path(設(shè)置搜索路徑)(設(shè)置搜索路徑) Use the Set Path dialog box to view and modify the MATLAB search path and see files in directories that are on the path. Select Set Path from the File menu, or type pathtool at the Command Window prompt. The Set Path dialog box opens. 搜索路徑是一系列文件路徑的組合。當(dāng)程序和命令執(zhí)行搜索路徑是一系列文件路徑的組合。當(dāng)程序和命令執(zhí)行時(shí),時(shí),MATLABMATLAB在搜索路徑中查找程序或命令運(yùn)行所需的函數(shù)在搜索路徑中查找程序或命令運(yùn)行所需的函數(shù)文件。文件。MATLABMATLAB在執(zhí)行搜索時(shí)按照規(guī)定的順序。如:在命令在執(zhí)行搜索時(shí)按照規(guī)定的順序。如:在命令窗口中輸入窗口中輸入exampleexample,MATLABMATLAB將按下面的將按下面的步驟步驟來(lái)處理:來(lái)處理:
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 防水購(gòu)銷(xiāo)合同范本年
- 比賽租賃游泳池合同書(shū)
- 工程款結(jié)算合同年
- 防水裝修合同協(xié)議書(shū)
- 紗線采購(gòu)合同
- 無(wú)息借款合同
- 有關(guān)廚房承包合同
- 2025合同債權(quán)與票據(jù)債權(quán)如何認(rèn)定
- 2025年金屬層狀復(fù)合材料項(xiàng)目提案報(bào)告范文
- 2025容器委托加工承攬合同書(shū)
- 小學(xué)六年級(jí)數(shù)學(xué)上冊(cè)《簡(jiǎn)便計(jì)算》練習(xí)題(310題-附答案)
- 地理標(biāo)志培訓(xùn)課件
- 2023行政主管年終工作報(bào)告五篇
- 2024年中國(guó)養(yǎng)老產(chǎn)業(yè)商學(xué)研究報(bào)告-銀發(fā)經(jīng)濟(jì)專(zhuān)題
- 培訓(xùn)如何上好一堂課
- 高教版2023年中職教科書(shū)《語(yǔ)文》(基礎(chǔ)模塊)下冊(cè)教案全冊(cè)
- 2024醫(yī)療銷(xiāo)售年度計(jì)劃
- 稅務(wù)局個(gè)人所得稅綜合所得匯算清繳
- 人教版語(yǔ)文1-6年級(jí)古詩(shī)詞
- 上學(xué)期高二期末語(yǔ)文試卷(含答案)
- 人教版英語(yǔ)七年級(jí)上冊(cè)閱讀理解專(zhuān)項(xiàng)訓(xùn)練16篇(含答案)
評(píng)論
0/150
提交評(píng)論