MATLAB讲义 (北京师范大学)第三章 (2学时) MATLAB程序设计.pdfVIP

  • 1
  • 0
  • 约1.81千字
  • 约 7页
  • 2017-11-13 发布于浙江
  • 举报

MATLAB讲义 (北京师范大学)第三章 (2学时) MATLAB程序设计.pdf

§4.1 M file – Scripts and Functions Main file forms in MATLAB • M文件(filename.m) • M文件(filename.m) two forms:Script file Function file • MAT文件(filename.mat) • MAT文件(filename.mat) MAT-files, the data file format MATLAB uses for saving data to your disk, provide a convenient mechanism for moving MATLAB data between platforms and for importing and exporting data to stand-alone MATLAB applications. • • 1. Script file A script file is an external file that contains a sequence of MATLAB statements. By typing the filename, you can obtain subsequent MATLAB input from the file. Script files have a filename extension of .m and are often called M-files. % commets end .m ; pause • % example421.m • % plot a sine wave • t=1:0.1:2*pi; • y=sin(t); • plot(t,y) • title(‘sin wave’) • save example421.m 2.Function file Matlab include a lot of standard functions. You add new functions to the MATLAB vocabulary by expressing them in terms of existing functions. The existing commands and functions that compose the new function reside in a text file called a M-file. §4.2 Data input and output  Menu in command window:file -》import data…。  通过与其它软件工具的接口输入数据  Load workspace variables (ASCII) from disk: enter (rows); space (datas) 。 §4.3 Flow Control Ⅰ.Repeat statements The general form: for . . .end , while. . . . end Ⅱ. Case transfer Two general forms of the transfer statement are: if . . . .end switch. . . case . . . end

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档