编辑: 苹果的酸 2019-07-11
Copyright ? 2013-2014 RM, All Rights Reserved.

测验 3-1 Copyright ? 2013-2014 RM, All Rights Reserved. 3-2 Copyright ? 2013-2014 RM, All Rights Reserved. ? 将同年的12月、1月和2月平均 ? 选择10:12作为冬季 3-3 Copyright ? 2013-2014 RM, All Rights Reserved. 小结 ? 变量 C 63字符,大小写混搭,首字母不为数值 ? 向量 C 方括号,冒号,分号 ? 矩阵 C 列优先 C 加减直接,乘法守法,点乘除直接 C sum和mean 3-4 主讲人:毛睿 北京师范大学 地表过程与资源生态国家重点实验室 Email: [email protected] 3/19/2015 Copyright ? 2014-2015 RM, All Rights Reserved. MATLAB及其在地学中的应用 第三讲 控制结构与函数 Copyright ? 2014-2015 RM, All Rights Reserved. 主要内容 逻辑数组函数函数中的变量控制结构逻辑数组 Copyright ? 2013-2014 RM, All Rights Reserved. 逻辑数组 ? 逻辑数组由0和1构成,用于访问数组 3-8 Copyright ? 2013-2014 RM, All Rights Reserved. 逻辑数组 3-9 Copyright ? 2013-2014 RM, All Rights Reserved. 关系运算符 ? 两个矩阵比较,size必须一致,点对点比较 ? 矩阵和scalar比较,scalar和矩阵的每个元素比较, 结果size与原矩阵size一致 ? 结果是真返回

1 ,非真返回

0 3-10 Copyright ? 2013-2014 RM, All Rights Reserved. 关系运算符 3-11 Copyright ? 2013-2014 RM, All Rights Reserved. 关系运算符 3-12 Copyright ? 2013-2014 RM, All Rights Reserved. 逻辑运算符 3-13 Copyright ? 2013-2014 RM, All Rights Reserved. 逻辑运算符 ? 两个矩阵比较,size必须一致,点对点比较 ? 矩阵和scalar比较,scalar和矩阵的每个元素比较结 果size与原矩阵size一致 ? ~、&和|可用于矩阵和scalar,&&和|| 只用于两 个scalar比较 3-14 Copyright ? 2013-2014 RM, All Rights Reserved. 逻辑运算符 3-15 Copyright ? 2013-2014 RM, All Rights Reserved. 逻辑数组运算 3-16 Copyright ? 2013-2014 RM, All Rights Reserved. 优先级 3-17 () ^,.^ 正负号, ~ +, - : & | && || 高低Copyright ? 2013-2014 RM, All Rights Reserved. 逻辑数组运算 3-18 Copyright ? 2013-2014 RM, All Rights Reserved. 逻辑数组运算 3-19 Copyright ? 2013-2014 RM, All Rights Reserved. 逻辑数组运算 3-20 Copyright ? 2013-2014 RM, All Rights Reserved. 逻辑数组运算 3-21 控制结构 Copyright ? 2013-2014 RM, All Rights Reserved. 控制结构 ? 条件结构,根据条件判断,再决定执行步骤 C If,all the elements of the logical expression are true C switch,scalar or string,case value in a cell array ? 循环结构,按照一定条件,重复执行某一步骤 C for,the number of passes is known C while,the number of passes is not known 3-23 Copyright ? 2013-2014 RM, All Rights Reserved. if ? logical_expression 所有元素 3-24 Copyright ? 2013-2014 RM, All Rights Reserved. if 3-25 Copyright ? 2013-2014 RM, All Rights Reserved. if 3-26 fprintf ?? Copyright ? 2013-2014 RM, All Rights Reserved. switch ? expression是scalar or string,case value in a cell array ? 将expression 依次与case 后的value比较,当比较结果为真,就 执行相应的语句组,然后跳出 switch 结构 ? 如果所有的比较结果都为假,则 执行 otherwise 后面的语句,然后 跳出 switch 结构 ? otherwise 可以不出现 3-27 Copyright ? 2013-2014 RM, All Rights Reserved. switch 3-28 Copyright ? 2013-2014 RM, All Rights Reserved. if和switch的区别 3-29 Copyright ? 2013-2014 RM, All Rights Reserved. for和while 3-30 Copyright ? 2013-2014 RM, All Rights Reserved. for 3-31 Copyright ? 2013-2014 RM, All Rights Reserved. for 3-32 Copyright ? 2013-2014 RM, All Rights Reserved. input、break和continue ? input,输入数值和字符串 ? break,终止循环,跳出最内层循环 ? continue,结束本次循环,以下语句不执行,进行 下一次循环 ? break和continue一般与if配合使用 3-33 Copyright ? 2013-2014 RM, All Rights Reserved. input、break和continue 3-34 Copyright ? 2013-2014 RM, All Rights Reserved. for和while的注意事项 ? 知道循环次数采用 for ,否则使用 while ? 循环语句可以嵌套使用 ? 不能在 for 循环体内改变iNum的值 ? 提高代码的向量化程度,多使用矩阵运算,避免 for 循环 3-35 函数 Copyright ? 2013-2014 RM, All Rights Reserved. 函数种类 ? 内置函数 ? 外置函数 C local and nested functions(子函数和嵌套函数) C private functions in a subfolder(隐函数) C anonymous functions without a file(匿名函数) ? s-function 3-37 Copyright ? 2013-2014 RM, All Rights Reserved. MATLAB的结构 ? Core functionality: compiled C-routines ? Most functionality is given as m-files, grouped into toolboxes ? Simulation of dynamical systems is performed in Simulink 1-38 m-files C-kernel Sig. Proc Simulink Contr. Syst. Copyright ? 2013-2014 RM, All Rights Reserved. local and nested functions in a file 3-39 help myfunction>squareMe Copyright ? 2013-2014 RM, All Rights Reserved. local and nested functions in a file 3-40 嵌套函数改变父函数变量,不能在控制结构中出现,嵌 套函数和父函数变量已经定义 Copyright ? 2013-2014 RM, All Rights Reserved. private functions in a subfolder 3-41 Copyright ? 2013-2014 RM, All Rights Reserved. anonymous functions without a file 3-42 Copyright ? 2013-2014 RM, All Rights Reserved. anonymous functions without a file 3-43 Copyright ? 2013-2014 RM, All Rights Reserved. anonymous functions without a file 3-44 Copyright ? 2013-2014 RM, All Rights Reserved. 函数优先级 3-45 Copyright ? 2014-2015 RM, All Rights Reserved. Preferences 1-46 Copyright ? 2013-2014 RM, All Rights Reserved. Set path 3-47 Copyright ? 2013-2014 RM, All Rights Reserved. 函数结构 3-48 function [s,c,t] = allTrig(x_deg) % input angle in degrees % output sin, cos, tan x_rad = 2*pi*x_deg./360;

下载(注:源文件不在本站服务器,都将跳转到源网站下载)
备用下载
发帖评论
相关话题
发布一个新话题