1. Trang chủ
  2. » Công Nghệ Thông Tin

Lecture 3 Creating M - files docx

17 397 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 17
Dung lượng 241,5 KB

Nội dung

Lecture Creating M-files Programming tools: Input/output (assign/graph-&-display) Repetition (for) Decision (if) © 2007 Daniel Valentine All rights reserved Published by Elsevier Review  Arrays – List of numbers in brackets  A comma or space separates numbers (columns)  A semicolon separates row – Zeros and ones Matrices:  zeros()  ones() – Indexing  (row,column) – Colon Operator:  Range of Data first:last or first:increment:last – Manipulating Arrays & Matrices  Transpose Input  Examples of input to arrays: – Single number array & scalar: 1×1 >> a = – Row array & row vector: 1×n >> b = [1 5] – Column array & column vector: nx1 >> b = b’ % This an application of the transpose – Array of n rows x m columns & Matrix: n × m >> c = [1 3; 6; 9] % This example is x Basic elements of a program  Input – Initialize, define or assign numerical values to variables  Set of command expressions – Operations applied to input variables that lead to the desired result  Output – Display (graphically or numerically) result An example of technical computing   Let us consider using the hyperbolic tangent to model a down-hill section of a snowboard or snow ski facility Let us first examine the hyperbolic tangent function by executing the command: >> ezplot( ‘tanh(x)’ ) We get the following graph: Ezplot(‘tanh(x)’) Hyperbolic tangent: tanh(X)  Properties (as illustrated in the figure): – – – – As X approaches –Inf, tanh(X) approaches -1 As X approaches Inf, tanh(X) approaches +1 X = 0, tanh(X) = Transition from -1 to is smooth and most rapid (roughly speaking) in the range -2

Ngày đăng: 07/03/2014, 08:20

TỪ KHÓA LIÊN QUAN

w