




已閱讀5頁,還剩7頁未讀, 繼續(xù)免費閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
大連交通大學(xué)2009屆本科生畢業(yè)設(shè)計(論文)外文翻譯外文原文introduction to matlabmatlab (short for matrix laboratory) is a special-purpose computer program optimized to perform engineering and scientific calculations. it started life has a program designed to perform matrix mathematics, but over the years it has grown into a flexible computing system capable of solving essentially any technical problem.the matlab program implements the matlab programming language and provides an extensive library of predefined functions that make technical programming tasks easier and more efficient. this book introduces the matlab language and shows how to use it to solve typical technical problems.matlab is a huge program, with an incredibly rich variety of functions. even the basic version of matlab without any toolkits is much richer than other technical programming languages. there are more than 1000 functions in the basic matlab product alone,and the toolkits extend this capability with many more functions in various specialties. this book makes no attempt to introduce the user to all of maltlabs own tools to locate the correct function for a specific purpose from the enormous choice available.advantages of matlab matlab has many advantages compared with conventional computer languages for technical problem solving. among them are the following:1. ease of usematlab is an interpreted language, like many versions of basic. like basic, it is very easy to use. the program can be used as a scratch pad to evaluate expressions typed at the command line, or it can be used to execute large prewritten programs. programs may be easily written and modified with the built-in integrated development environment, and debugged with the matlab debugger. because the language is so easy to use, it is ideal for educational use, and for the rapid prototyping of new programs. many program development tools are provided to make the program easy to use. a workspace browser, and extensive demos.2. platform independence matlab is supported on many different computer systems, providing a large measure of platform independence. at the time of this writing, the language is supported on windows 9x/nt/2000 and many different versions of unix. programs written on any platform will run on all of the other platforms, and data files written on any platform may be read transparently on any other platforms, as a result,programs written in matlab can migrate to new platforms when the needs of the user change.3. predefined functionsmatlab comes complete with an extensive library of predefined functions that provide tested and prepackaged solutions to many basic technical tasks. for example, suppose that you are writing a program that must calculate the statistics associated with an input data set. in most languages, you would need to write your own subroutines or functions to implement calculations such as the arithmetic mean, standard deviation, median, and so forth. these and hundreds of other functions are built right into the matlab language, making your job much easier.in addition to the large library of functions built into the basic matlab language, many special-purpose toolboxes are available to help solve complex problems in specific areas. for example, a user can buy standard toolboxes to solve problems in signal processing, control systems, communications, image processing, and neural networks, among many others. there is also an extensive collection of free user-contributed matlab programs that are shared through the matlab web site.4. device-independent plottingunlike most 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 user interfacematlab 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. matlab compilermatlabs flexibility and platform independence is achieved by compiling matlab programs into a device-independence p-code, and then interpreting the p-code instructions at run time. this approach is similar to that used by microsoft is visual basic language. unfortunately, the resulting programs can sometimes execute slowly because the matlab code is interpreted rather than compiled. we will point out features that tend to slow program execution when we encounter them. a separate matlab compiler is available. this compiler can compile a matlab program into a true executable that runs faster than the interpreted code. it is a great way to convert a prototype matlab program into an executable suitable for sale and distribution to users.disadvantages of matlab matlab has two principal disadvantages. the first is that it is an interpreted 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 distribution and general use.the second disadvantage is cost: a full copy of matlab is 5 to 10 times more expensive than a conventional c or fortran compiler. this relatively high cost is more than offset by the reduced time required for an engineer or scientist to create a working program, so matlab is cost-effective for businesses. however, it is too expensive for most individuals to consider purchasing. fortunately, there is also an inexpensive student edition of matlab, which is a great tool for students wanting to learn the language. the student edition of matlab is essentially identical to the full edition.with the introduction of branches and loops, our programs are going to become more complex, and it will get easier to make mistakes. to help avoid programming errors, we will introduce a formal program design procedure based on the technique known as top-down design. we will also introduce a common algorithm development tool known as pseudo code.introduction to top-down design techniquessuppose that you are an engineer working in industry, and that you need to write a program to solve some problem. how do you begin? when given anew problem, there is a natural tendency to sit down at a keyboard and start programming without “wasting” a lot of time thinking about the problem first. it is often possible to get away with this “on the fly” approach to programming for very small problems, such as many of the examples in this book. in the real world, however, problems are larger, and a programmer attempting this approach will become hopelessly bogged down. for larger problems, it pays to completely think out the problem and the approach you are going to take to it before writing a single line of code. we introduce a formal program design process in this section, and then apply that process to every major application developed in the remainder of the book. for some of the simple examples that we will be doing, the design process will seem like overkill; however, as the problems that we solve get larger and larger, the process becomes more and more essential to successful programming.when i was an undergraduate, one of my professors was fond of saying, “programming is easy. it is knowing what to program that is hard.” his point was forcefully driven home to me after i left university and began working in industry on larger scale software projects. i found that the most difficult port of my job was to understand the problem i was trying to solve. once i really understood the problem, it became easy to break the problem apart into smaller, more easily manageable pieces with well-defined functions, and then to tackle those pieces one at a time.top-down design is the process of starting with a large task and breaking it down into smaller, more easily understandable pieces, which perform a portion of the desired task. each subtask may in turn be subdivided into smaller subtasks if necessary. once the program is divided into small pieces, each piece can be coded and tested independently. we do not attempt to combine the subtasks into a complete task until each of the subtasks has been verified to work properly by itself.the concept of top-down design is the basis of our formal program design process. we will now introduce the details of the process, which is illustrated in figure 1 the steps involved are:1. clearly state the problem that you are trying to solve.programs are usually written to fill some perceived need, but that need may not be articulated clearly by the person requesting the program. for example, a user may ask for a program to solve a system of simultaneous linear equations. this request is not clear enough to allow a programmer to design a program to meet the need; he or she must first know much more about the problem to be solved. is the system of equations to be solved real or complex? what is the maximum number of equations and unknown that the program must handle? are there any symmetry in the equations that might be exploited to make the task easier? the program designer will have to talk with the user requesting the program, and the two of them will have come up with a clear statement of exactly what they are trying to accomplish. a clear statement of the problem will prevent misunderstandings, and it will also help the program designer to properly organize his or her thoughts. in the example we were describing, a proper statement of the problem might have been: figure 1design and write a program to solve a system of simultaneous linear equations having real coefficients and with up to 20 equations in 20 unknowns.2. define the inputs required by the program and the outputs to be produced by the program.the inputs to the program and the outputs produced by the program must be specified so that the new program will properly fit into the overall processing scheme. in this example, the coefficients of the equations to be solved are probably in some pre-existing order, and our new program needs to be able to read them in that order. and our new program needs to be able to read them in that order. similarly, it needs to produce the answers required by the programs that may follow it in the overall processing scheme, and to write out those answers in the format needed by the programs following it.3. design the algorithm that you intend to implement in the program.an algorithm is a step-by-step procedure for finding the solution to a problem. it is at this stage in the process that top-down design techniques come into play. the designer looks for logical divisions within the problem, and divides it up into subtasks along those lines. this process is called decomposition. if the subtasks are large, the designer can break them up into even smaller sub-tasks. this process continues until the problem has been divided into many small pieces, each of which does a simple, clearly understandable job.after the problem has been decomposed into small pieces, each piece is further refined through a process called stepwise refinement. in stepwise refinement, a designer starts with a general description of what the piece of code should do, and then defines the functions of the piece in greater and greater detail until they are specific enough to be turned into matlab statements. stepwise refinement is usually done with pseudo code, which will be described in the next section.it is often helpful to solve a simple example of the problem by hand during the algorithm development process. if the designer understands the steps that he or she went through in solving the problem by hand, then he or she will be better able to apply decomposition and stepwise refinement to the problem.4. turn the algorithm into matlab statements.if the decomposition and refinement process was carried out properly, this step will be very simple. all the programmer will have to do is to replace pseudo code with the corresponding matlab statements on a one-for-one basis.5. test the resulting matlab programthis step is the real killer. the components of the program must first be tested individually, if possible, and then the program as a whole must be tested. when testing a program, we must verify that it works correctly for all legal input data sets. it is very common for a program to be written, tested with some standard data set, and released for use, only to find that it produces the wrong answers (or crashes) with a different input data set. if the algorithm implemented in a program includes different branches, we must test all of the possible branches to confirm that the program operates correctly under every possible circumstance.large programs typically go through a series of tests before they are released for general use (see figure 2). the first stage of testing is sometimes called unit testing. during unit testing, the individual subtasks of the program are tested separately to confirm that they work correctly. after the unit testing is completed, the program goes through a series of builds, during which the individual subtasks are combined to produce the final program. the first build of the program typically includes only a few of the subtasks. it is used to check the interactions among those subtasks and the functions performed by the combinations of the subtasks. in successive builds, more and more subtasks are added, until the entire program is complete. testing is performed on each build, and any errors(bugs) detected are corrected before moving on to the next build. figure 2中文翻譯matlab 介紹matlab (矩陣實驗室的簡稱)是一種專業(yè)的計算機程序,用于工程科學(xué)的矩陣數(shù)學(xué)運算。但在以后的幾年內(nèi),它逐漸發(fā)展為一種極其靈活的計算體系,用于解決各種重要的技術(shù)問題。matlab 程序執(zhí)行matlab 語言,并提供了一個極其廣泛的預(yù)定義函數(shù)庫,這樣就使得技術(shù)工作變得簡單高效。本書將介紹matlab 語言,并向大家展示如何運用它去解決經(jīng)典的技術(shù)問題。matlab 是一個龐大的程序,擁有難以置信的各種豐富的函數(shù);即使基本版本的matlab 語言擁有的函數(shù)也比其他的工程編程語言要豐富的多。基本的matlab 語言已經(jīng)擁有了超過1000 多個函數(shù),而它的工具包帶有更多的函數(shù),由此擴展了它在許多專業(yè)領(lǐng)域的能力。本書無意將matlab 的所有函數(shù)介紹給大家,而是讓大家掌握編寫調(diào)試和優(yōu)化程序的基本功,還有一些重要函數(shù)的子集。所以從大量可利用的函數(shù)中篩選出你所需要的函數(shù)就顯得尤為重要。matlab 的優(yōu)點matlab 語言相對于傳統(tǒng)的科技編程語言有諸多的優(yōu)點。主要包括:1.易用性matlab 是種解釋型語言,就像各種版本的basic。和basic 一樣,它簡單易用程序可用作便箋簿求打在命令行處表達式的值,也可執(zhí)行預(yù)先寫好的大型程序。在matlab 集成開發(fā)環(huán)境下,程序可以方便的編寫,修改和調(diào)試。這是因為這種語言極易使用,對于教育應(yīng)用和快速建立新程序的原型,它是一個理想的工具。許多的編程工具使得 matlab 十分簡單易用。這些工具包括:一個集成的編譯/調(diào)試器,在線文件手冊,工作臺和擴展范例。2.平臺獨立性matlab 支持許多的操作系統(tǒng),提供了大量的平臺獨立的措施。在本書編寫的時侯, windows98/2000/nt 和許多版本的unix 系統(tǒng)都支持它。在一個平臺上編寫的程序,在其它平臺上一樣可以正常運行,在一個平臺上編寫的數(shù)據(jù)文件在其它平臺上一樣可以編譯。因此用戶可以根據(jù)需要把matlab 編寫的程序移植到新平臺。3.預(yù)定義函數(shù)matlab 帶有一個極大的預(yù)定義函數(shù)庫,它提供了許多已測試和打包過的基本工程問題的函數(shù)。例如,假設(shè)你正在編寫一個程序,這個程序要求你必須計算與輸入有關(guān)的統(tǒng)計量。在許多的語言中,你需要寫出你所編數(shù)組的下標和執(zhí)行計算所需要的函數(shù),這些函數(shù)包括其數(shù)學(xué)意義,中值,標準誤差等。像這樣成百上千的函數(shù)已經(jīng)在matlab 中編寫好,所以讓編程變得更加簡單。除了植入matlab 基本語言中的大量函數(shù),還有許多專用工具箱,以幫助用戶解決在具體領(lǐng)域的復(fù)雜問題。例如,用戶可以購買標準的工具箱以解決在信號處理,控制系統(tǒng),通信,圖象處理,神經(jīng)網(wǎng)絡(luò)和其他許多領(lǐng)域的問題。4.機制獨立的畫圖與其他語言不同,matlab 有許多的畫圖和圖象處理命令。當matlab 運行時,這些標繪圖和圖片將會出現(xiàn)在這臺電腦的圖像輸出設(shè)備中。此功能使得matlab 成為一個形象化技術(shù)數(shù)據(jù)的卓越工具。5.用戶圖形界面matlab 允許程序員為他們的程序建立一個交互式的用戶圖形界面。利用matlab 的這種功能,程序員可以設(shè)計出相對于無經(jīng)驗的用戶可以操作的復(fù)雜的數(shù)據(jù)分析程序。6.matlab 編譯器matlab 的靈活性和平臺獨立性是通過將matlab 代碼編譯成設(shè)備獨立的p 代碼,然后在運行時解釋p 代碼來實現(xiàn)的。這種方法與微軟的vb 相類似。不幸的是,由于matlab 是解釋性語言,而不是編譯型語言,產(chǎn)生的程序執(zhí)行速度慢。當我們遇到執(zhí)行速度慢的程序時,我們將會指出其這一特性。matlab 的缺點matlab 有兩個基本的缺點。第一,它是解釋型語言,其執(zhí)行速度要比編譯型語言慢得多。這個問題可以通過合理的matlab 結(jié)構(gòu)得到緩解,也可以在發(fā)行廣泛使用前編譯出matlab 程序。第二,他的費用較高。一個完全版matlab 編譯器的大小是一個c 語言或fortan 語言編譯器的5 到10倍。但matlab 能夠節(jié)省大量的時間在科技編程方面,故matlab 在商業(yè)編程過程中是節(jié)省成本的。盡管如此,相對于大多數(shù)考慮購買的人還是很昂貴的。幸運的是,它有一個價格便宜的學(xué)生專用版本,對學(xué)生來說它是學(xué)習(xí)matlab 語言的一個重要工具。學(xué)生版的matlab和完全版的matlab 是基本一致的。隨著選擇和循環(huán)介紹,我們的程序也將變得復(fù)雜,對于解決問題來說,將會變得簡單。為了幫助大家避免在編程過程中出現(xiàn)大量的錯誤,我們將向大家介紹正式的編程步驟,即自上而下的編程方法。我們也會向大家介紹一些普通的算法開發(fā)工具即偽代碼。自上而下的編程方法簡介假設(shè)你是在工廠工作的工程師,為了解決某些問題,你要編寫一個程序。你如何開始呢?當遇到一個新問題時,我們的心里會自然而然的產(chǎn)生這樣的想法:馬上坐在計算機前
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 福建寧德2024~2025學(xué)年高一下冊期末質(zhì)量檢測數(shù)學(xué)試題學(xué)生卷
- 相聲中的即興表演技巧考核試卷
- 鄉(xiāng)土民俗資源在內(nèi)陸?zhàn)B殖產(chǎn)業(yè)升級中的作用考核試卷
- 農(nóng)藥廢水處理中吸附材料研究動態(tài)考核試卷
- 上海市普陀區(qū)2024-2025學(xué)年七年級(五四制)下學(xué)期期末語文試題(含答案)
- 絲印印刷品背面油墨凝固問題及處理技巧考核試卷
- 食品安全分子檢測中的免疫分析技術(shù)進展分析考核試卷
- 2025年中國PP-R粉碎下角料數(shù)據(jù)監(jiān)測報告
- 2025年中國MPEG測試儀數(shù)據(jù)監(jiān)測研究報告
- 2025年中國FD管理冊數(shù)據(jù)監(jiān)測報告
- 2025年遼寧沈陽地鐵集團有限公司招聘筆試參考題庫含答案解析
- 2025年全國水務(wù)集團招聘筆試參考題庫含答案解析
- 阿細跳月課件
- 藥品召回管理辦法
- 網(wǎng)絡(luò)物流保險行業(yè)發(fā)展概況及未來五年行業(yè)數(shù)據(jù)趨勢預(yù)測
- 2024年山東濟南初中學(xué)業(yè)水平考試物理試卷真題(含答案詳解)
- 初三九年級化學(xué)全冊導(dǎo)學(xué)案(人教新課標版)
- 校園除草課件
- 成都市2022級(2025屆)高中畢業(yè)班摸底測試(零診)數(shù)學(xué)試卷(含答案)
- 門靜脈血栓的介入治療
- SL721-2015水利水電工程施工安全管理導(dǎo)則
評論
0/150
提交評論