TAILIEUCHUNG - Electronics and Circuit Analysis using MATLAB P2

Normally, when single line commands are entered, MATLAB processes the commands immediately and displays the results. MATLAB is also capable of processing a sequence of commands that are stored in files with extension m. MATLAB files with extension m are called m-files. The latter are ASCII text files, and they are created with a text editor or word processor. To list m-files in the current directory on your disk, you can use the MATLAB command what. The MATLAB command, type, can be used to show the contents of a specified file. M-files can either be script files or function files | M-FILES Normally when single line commands are entered MATLAB processes the commands immediately and displays the results. MATLAB is also capable of processing a sequence of commands that are stored in files with extension m. MATLAB files with extension m are called m-files. The latter are ASCII text files and they are created with a text editor or word processor. To list m-files in the current directory on your disk you can use the MATLAB command what. The MATLAB command type can be used to show the contents of a specified file. M-files can either be script files or function files. Both script and function files contain a sequence of commands. However function files take arguments and return values. Script files Script files are especially useful for analysis and design problems that require long sequences of MATLAB commands. With script file written using a text editor or word processor the file can be invoked by entering the name of the m-file without the extension. Statements in a script file operate globally on the workspace data. Normally when m-files are executing the commands are not displayed on screen. The MATLAB echo command can be used to view m-files while they are executing. To illustrate the use of script file a script file will be written to simplify the following complex valued expression z. Example Simplify the complex number z and express it both in rectangular and polar form. 3 j4 5 j2 2Z60 z ------------- ------------ 3 j6 1 j 2 Solution The following program shows the script file that was used to evaluate the complex number z and express the result in polar notation and rectangular form. MATLAB Script diary 1999 CRC Press LLC Evaluation of Z the complex numbers are entered Z1 3 4 j Z2 5 2 j theta 60 180 pi angle in radians Z3 2 exp j theta Z4 3 6 j Z5 1 2 j Z_rect is complex number Z in rectangular form disp Z in rectangular form is displays text inside brackets Z_rect Z1 Z2 Z3 Z4 Z5 Z_rect Z_mag abs Z_rect magnitude of

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.