这里有些常见错误提示信息供大家参考 1.Subscript indices must either be real positive integers orlogicals 中文解释:下标索引必须是正整数类型或者逻辑类型 出错原因:在访问矩阵(包括向量、二维矩阵、多维数组,下同)的过程中,下标索引要么从 0 开始,要么出现了负数。注:matlab的语法规定矩阵的索引从 1 开始,这与 C 等编程语言的习惯不一样。 解决办法:自己调试一下程序,把下标为 0 或者负数的地方修正。 2.Undefined function or variable "a" 中文解释:函数或变量 a 没有定义 3.Input argument "x" is undefined 中文解释:输入变量 x 没有定义 4.Matrix dimensions must agree Inner matrix dimensions must agree 中文解释:矩阵的维数必须一致 出错原因:这是由于运算符(= + - / * 等)两边的运算对象维数不匹配造成的,典型的出错原因是错用了矩阵运算符。matlab通过“.”来区分矩阵运算和元素运算 5.Function definitions are not permitted at the prompt or inscripts 中文解释:不能在命令窗口或者脚本文件中定义函数 出错原因:一旦在命令窗口写 function c = myPlus(a,b),此错误就会出现,因为函数只能定义在 m 文件中 6. 1) X must have one or two columns 2)Vectors must be the samelengths 中文解释: 1. X 必须是 1 或者 2 列 2. 向量长度必须一致 7.One or more output arguments not assigned during call to'...' 中文解释:在调用...函数过程中,一个或多个输出变量没有被赋值 8.??? Error using ==> mpower Matrix must be square 中文解释:错误使用mpwoer函数,要求矩阵必须是方阵 9.Explicit integral could not be found. 中文解释:显式解没有找到 10.Index exceeds matrix dimensions. Attempted to access b(3,2); index out of bounds becausesize(b)=. 中文解释:索引超出矩阵的范围 11.In an assignment A(I) =B, the number of elements in B and I must be the same 中文解释:在赋值语句 A(I) = B 中,B 和 I 的元素个数必须相同 12.To RESHAPE the number of elements must not change 中文解释:矩阵变换时,变换前和变换后的总元素不能改变
2.善于利用MATLAB的帮助 一遇到什么问题,通常我的第一反应是:help,就先说说自己对help的一些常用方法吧。 1)命令窗口直接敲“help”,你就可以得到本地机器上matlab的基本的帮助信息。 2)对于某些不是很明确的命令,只知道大体所属范围,譬如说某个工具箱,直接在命令窗口中敲入 Help toolboxname,一帮可以得到本工具箱有关的信息:版本号,函数名等。 3)知道函数名,直接用help funname就可以得到相应的帮助信息。