Lecture 3 Creating M - files docx

17 396 0
Lecture 3 Creating M - files docx

Đ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

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

Mục lục

  • Lecture 3 Creating M-files

  • Review

  • Input

  • Basic elements of a program

  • An example of technical computing

  • Ezplot(‘tanh(x)’)

  • Hyperbolic tangent: tanh(X)

  • Problem background

  • Formula for snow hill shape

  • Problem statement

  • Structure plan

  • Slide 12

  • Use of repetition (‘for’)

  • Slide 14

  • Decision: Application of ‘if’

  • Slide 16

  • Summary

Tài liệu cùng người dùng

Tài liệu liên quan