当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

同济大学:《Matlab在机械设计中的应用》课程电子教案(PPT课件)Chapter 02 MATLAB Basics(负责人:陈明)

资源类别:文库,文档格式:PPT,文档页数:47,文件大小:2.1MB,团购合买
Part 1: Variables and Arrays Part 2: Multidimensional Arrays Part 3: Subarrays Part 4: Special Values Part 5: Displaying Output Data Part 6: Scalar and Array Operations Part 7: Hierarchy of Operations Part 8: Built-in Functions
点击下载完整版文档(PPT)

Chapter 2:MATLAB Basics Part 1:Variables and Arrays Part 2:Multidimensional Arrays ▣Part3:Subarrays Part 4:Special Values Part 5:Displaying Output Data Part 6:Scalar and Array Operations Part 7:Hierarchy of Operations Part 8:Built-in Functions 细月济大学 TONGJI UNIVERSITY

Chapter 2: MATLAB Basics  Part 1: Variables and Arrays  Part 2: Multidimensional Arrays  Part 3: Subarrays  Part 4: Special Values  Part 5: Displaying Output Data  Part 6: Scalar and Array Operations  Part 7: Hierarchy of Operations  Part 8: Built-in Functions

MATLAB Basics(1/40) Variables and Arrays Variable is a name given to a reserved location in memory 。class code=l1l; number of students =65; name ="Tongji University'; radius 5; area pi radius 2; @日济大学 TONGJI UNIVERSITY

➢ Variable is a name given to a reserved location in memory • class_code = 111; • number_of_students = 65; • name = ‘Tongji University’; • radius = 5; • area = pi * radius^2; MATLAB Basics(1/40) Variables and Arrays

MATLAB Basics(2/40) Variables and Arrays Use meaningful names for variables MATLAB variable names .must begin with a letter can contain any combination of letters,numbers and underscore ( must be unique in the first 31 characters >MATLAB is case sensitive: ·“name',Name”and“NAME”are considered different variables Never use a variable with the same name as a MATLAB command CPHAW Naming convention:use lowercase letters 月停大学 TONGJI UNIVERSITY

MATLAB Basics(2/40) Variables and Arrays ➢ Use meaningful names for variables ➢ MATLAB variable names • must begin with a letter • can contain any combination of letters, numbers and underscore (_) • must be unique in the first 31 characters ➢ MATLAB is case sensitive: • “name”, “Name” and “NAME” are considered different variables ➢ Never use a variable with the same name as a MATLAB command ➢ Naming convention: use lowercase letters

MATLAB Basics(3/40) Variables and Arrays >The fundamental unit of data is array colurgealar vector row 3 1 -3 11 15 -2 3 21 1 0 13 matrix @日济大学 TONGJI UNIVERSITY

MATLAB Basics(3/40) Variables and Arrays ➢ The fundamental unit of data is array 3 scalar 1 -3 11 vector 15 -2 3 21 -4 1 0 13 matrix row column

MATLAB Basics(4/40) Variables and Arrays >Three common ways to initialize a variable in the MATLAB Assign data to the variable in an assignment statement Input data into the variable from the keyboard ·Read data from a file CDHAW 同你大学 TONGJI UNIVERSITY

MATLAB Basics(4/40) Variables and Arrays ➢ Three common ways to initialize a variable in the MATLAB • Assign data to the variable in an assignment statement • Input data into the variable from the keyboard • Read data from a file

MATLAB Basics(5/40) Variables and Arrays Initialization using assignment statements 。X=5 X= 5 。y=x+1 y= 6 ·vector=[1234] vector 1234 @日济大学 TONGJI UNIVERSITY

MATLAB Basics(5/40) Variables and Arrays ➢ Initialization using assignment statements • x = 5 x = 5 • y = x + 1 y = 6 • vector = [ 1 2 3 4 ] vector = 1 2 3 4

MATLAB Basics(6/40) Variables and Arrays ·matrix=[123,456] matrix 123 456 ·matrix=[123;45] ??Error ·a=[5(2+4)] a= CDHAW 56 @月诱大学 TONGJI UNIVERSITY

MATLAB Basics(6/40) Variables and Arrays • matrix = [ 1 2 3; 4 5 6 ] matrix = 1 2 3 4 5 6 • matrix = [ 1 2 3; 4 5 ] ??? Error • a = [ 5 (2+4) ] a = 5 6

MATLAB Basics(7/40) Variables and Arrays > Initialization using shortcut statements colon operator->first increment last ·x=1:2:10 X= 13579 °y=0:0.1:0.5 y= 00.10.20.30.40.5 @日济大学 TONGJI UNIVERSITY

MATLAB Basics(7/40) Variables and Arrays ➢ Initialization using shortcut statements ✓ colon operator → first : increment : last • x = 1:2:10 x = 1 3 5 7 9 • y = 0:0.1:0.5 y = 0 0.1 0.2 0.3 0.4 0.5

MATLAB Basics(8/40) Variables and Arrays √transpose operator→' ·u=[1:3] U= 1 2 v=[uu] 11 2 2 3 ·V= u] CDHAW V= 1 2 3 @月诱大学 TONGJI UNIVERSITY 123

MATLAB Basics(8/40) Variables and Arrays ✓ transpose operator → ’ • u = [ 1:3 ]' u = 1 2 3 • v = [ u u ] v = 1 1 2 2 3 3 • v = [ u'; u' ] v = 1 2 3 1 2 3

MATLAB Basics(9/40) Variables and Arrays Initialization using built-in functions √ zeros()ones() √size)length() ·x=zeros(2) y=ones(size(x)) X- y= 00 11 00 11 ·z=ones(2,3) ·t=zeros(length(z)) t= 111 0 0 0 111 0 0 0 0 0 0 LENGTH(X)returns the length of vector X. It is equivalent to MAX(SIZE(X))for non- 同濟大学 TONGJI UNIVERSITY empty arrays and 0 for empty ones

MATLAB Basics(9/40) Variables and Arrays ➢ Initialization using built-in functions ✓ zeros() ones() • x = zeros(2) x = 0 0 0 0 • z = ones(2,3) z = 1 1 1 1 1 1 ✓ size() length() • y = ones(size(x)) y = 1 1 1 1 • t = zeros( length(z) ) t = 0 0 0 0 0 0 0 0 0 LENGTH(X) returns the length of vector X. It is equivalent to MAX(SIZE(X)) for non￾empty arrays and 0 for empty ones

点击下载完整版文档(PPT)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共47页,可试读16页,点击继续阅读 ↓↓
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有