中国高校课件下载中心 》 教学资源 》 大学文库

上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_15 Introduction to matlab

文档信息
资源类别:文库
文档格式:PDF
文档页数:52
文件大小:394.75KB
团购合买:点击进入团购
内容简介
上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_15 Introduction to matlab
刷新页面文档预览

上海交通大学交大密西根 联合学院·一 ◆] 181 UM-SJTU Joint Institute ■ University of Michigan Shanghal Jiao Tong University Vg101 Introduction to Computer and Programming Programming In MATLAB

Vg101 Introduction to Computer and Introduction to Computer and Programming Programming Programming In MATLAB

上海交通大学交大密西根 联合学院· 81 UM-SJTU Joint Institute University of Michigan Shanghal Jiao Tong University What is MATLAB It is a high-performance language for technical computing.It integrates computation, visualization,and programming environment. 。 it is a also modern programming language environment:it has sophisticated data structures,contains built-in editing and debugging tools,and supports object-oriented programming. It has many advantages compared to C/C++for solving engineering problems

What is MATLAB What is MATLAB • It is a high-performance language for technical computing. It integrates computation, visualization, and programming environment. • it is a also modern programming language environment: it has sophisticated data structures, contains built-in editing and debugging tools, and supports object-oriented programming. • It has many advantages compared to C/C++ for solving engineering problems

上海交通大学交大密西根 联合学院一 181 UM-SJTU Joint Institute University of Michigan Shanghal Jiao Tong University Examples with MatLab For example,suppose you wanted to plot sin(2 t) Figure 1 日▣☒ Eile Edit Yiew Insert Iools Detktep Yindow Help ·MatLab Commands D宝日色6®Q”®银口国国▣ >>t=-2*pi:pi/100:2*pi; 08 >>plot(t,sin(2*t)); 06 0.4 the first command I means 02 that t is equal to the 02 ordered set of numbers from-2*pi to 2*pi in 0.8 increments of 0.01*pi

Examples with Examples with MatLab • For example, suppose you wanted to plot sin(2 t) • MatLab Commands >> t=-2*pi:pi/100:2*pi; >> plot(t, sin(2*t)); • the first command means that t is equal to the ordered set of numbers from –2*pi to 2*pi in increments of 0.01*pi

上海交通大学交大密西根 联合学院·一 ◆] 181t UM-SJTU Joint Institute University of Michigan Shanghal Jiao Tong University Examples with MatLab Visualizing the equation fxy)=e0.2x0.2 cos(x2y2 over the domain{x×y:x∈[-4,4],y∈[-4,4]} With the LatLab commands like >>[8,Y]=me3 ngrid(-4:.05:4); >>Z=co3(x.人2+Y.^2).*exp(.2*x).*exp(.2*Y); >surfl(X,Y,Z) Plot of z=f(x,y)

Examples with Examples with MatLab • Visualizing the equation over the domain • With the LatLab commands like • Plot of z = f (x, y)

Men us charge. doponding an the U5a1ab灯g0 Mow ar Mava Com and Widow cutsida of laol you are to Workspace Get help changecurren1 dBk的p(udoX currontly using browser. diredory MATLAB Eile Edit Dobug 上askop Wndow Halp 色 D:mmi ies 图 htc支g内oto add Whet's New Current Darectory m. Command Window X F5上 《且人TLA5> Fle Twe bucky.m N-file Copyright 1984-2005 Tha Nathborxe,Ine. caution.mdl Model Vetsion 7.0.4 |R198P21 ■collaizall.asy Editor Aute To get atarted,select NATlAB Heln or Demog from th Qumort Dlre ctory 灯tFse Command History 5---2/23/D4 3:59P1--4 noE画an formet long e -ca d:/myntiles/sea_te -claar -vorkspage dStart Cick start View or axecute Drag the separator bar Enter MATLAB functions a1 button for guck proviously run functions to rasizo wrdaws command-no p on pt. access to tools from he Conmand and more Histo ry window

Started with Started with MatLab MatLab

上海交通大学交大密西根 联合学院一 ◆ UM-SJTU Joint Institute 1Ua日 181t ■ University of Michigan Shanghal Jiao Tong University Calculating with MatLab Direct calculation,ans the default variable for answer,you can name a variable and do arithmetic calculation as in a calculator >>1+2*3 >>X=1+2*3 >>4*X ans X = ans 7 7 28.0000 Table 1.1:Basic arithmetic operators SYMBOL OPERATION EXAMPLE Addition 2+3 Subtraction 2-3 Multiplication 2*3 Division 2/3

Calculating with Calculating with MatLab • Direct calculation, ans the default variable for answer, you can name a variable and do arithmetic calculation as in a calculator

上海交通大学交大密西根 联合学院一 ◆ 1811 UM-SJTU Joint Institute University of Michigan Shanghal Jiao Tong University Started with MatLab Overwrite a variable >> t=5; >>t= t+1 t 6 ·Error message >>X= 10; >>5x ???5x I Error:Unexpected MATLAB expression. ·Precedence >>(1+2)*3 ans 9

Started with Started with MatLab • Overwrite a variable • Error Message • Precedence

上海交通大学交大密西根 联合学院· UM-SJTU Joint Institute University of Michigan Shanghal Jiao Tong University Started with MatLab Display format:Inside MatLab,there is only one date type:double,has 15 digits accuracy >format short >> format long >x=-163.6667 >>x=-1.636666666666667e+002 Get Help,type help command after > 。 Hold the display:putting“;”at the end of a command,will hold display Clear working space:“clear”or“clear all''will erase all the defined variables

Started with Started with MatLab • Display format: Inside MatLab, there is only one date type: double, has 15 digits accuracy • Get Help, type help command after >> • Hold the display: putting “;” at the end of a command, will hold display • Clear working space: “clear” or “clear all” will erase all the defined variables

上海交通大学交大密西根 ·联合学院一 181 UM-SJTU Joint Institute University of Michigan Shanghal Jiao Tong University Math Functions in MatLab cos(x) Cosine abs(x) Absolute value sin(x) Sine sign(x) Signum function tan(x) Tangent max (x) Maximum value acos(x) Arc cosine min(x) Minimum value asin(x) Arc sine ceil(x) Round towards +oo atan(x) Arc tangent floor(x) Round towards -o exp(x) Exponential round(x) Round to nearest integer sqrt (x) Square root rem(x) Remainder after division log(x) Natural logarithm angle(x) Phase angle 1og10(x) Common logarithm conj(x) Complex conjugate

Math Functions in Math Functions in MatLab

上海交通大学交大密西根 联合学院一 ◆] 1811 UM-SJTU Joint Institute University of Michigan Shanghal Jiao Tong University Predefined constants in MatLab Table 2.2:Predefined constant values pi The number,=3.14159... i,j The imaginary unit i,v-1 Inf The infinity,o NaN Not a number

Predefined constants in Predefined constants in MatLab

刷新页面下载完整文档
VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
相关文档