TAILIEUCHUNG - A Guide to MATLAB for Chemical Engineering Problem Solving phần 2

Matlab kịch bản, còn được gọi là các macro, các chương trình, mã, M-file, chỉ đơn giản là bộ sưu tập các lệnh. Mã này được xây dựng trong cửa sổ chỉnh sửa M-FILE, hoạt động giống như một trình soạn thảo văn bản. Trong thực tế, một file M-là chỉ asimple tập tin văn bản ASCII, và có thể được tạo ra và chỉnh sửa bởi bất kỳ trình soạn thảo văn bản đơn giản, mặc dù, nó có lẽ là dễ dàng hơn để sử dụng các trình soạn thảo trong Matlab | IV. Matlab Scripts and function files M-files NOTE Both script files and function files MUST have the file extension .m appended to the filename. TIP Be careful While fiddling with small changes in a script it is all too easy to overwrite a script that you wanted to keep with one that you don t. Save your changes to a separate file with a unique name first. THEN use th e SAVE EXECUTE command. Matlab Scripts Matlab scripts also known as macros programs code M-files are simply collections of commands. The code is constructed in the M-FILE editing window which operates just like a text editor. In fact an M-file i just a simple ASCII text file and can be created and edited by any simple text editor although it is probably easier to use the editor in Matlab. Each line should b e entered just as if you were to enter it at the command prompt in the COMMAND window. When you have finished editing save your work IN YOUR FOLDER OR ON YOUR DISK as a M-file. In order to be recognized by Matlab as a valid M-file it MUST have the file extension .m appended to the file name. To actually execute your code use the Save and Execute command under the FILE pull down menu E is the keyboard equivalent . Note that this command first saves your file to disk overwriting the previous version of your script o f that particular name without even asking first It then runs the code. Another important tool in writing Matlab scripts is the use of comment lines. Matlab will ignore all characters after the percent sign on a given line. It is impossible for others to evaluate and modify your code if they can t understand what your variables stand for and what steps your code performs. In order to receive full credit any homework solution solved using Matlab or any other computer code must include a printout of the code used. Comment lines should be used to provide definitions for all the variables used and the appropriate units. Example Start with a fresh M-file editing window. Write a script to .

TỪ KHÓA LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.