Matlabxcode indexingg cannot yield multiple results.

的海词问答和网友补充:
相关词典网站:21903人阅读
一、矩阵的表示
在MATLAB中创建矩阵有以下规则:
a、矩阵元素必须在”[ ]”内;
b、矩阵的同行元素之间用空格(或”,”)隔开;
c、矩阵的行与行之间用”;”(或回车符)隔开;
d、矩阵的元素可以是数值、变量、表达式或函数;
e、矩阵的尺寸不必预先定义。
二,矩阵的创建:
1、直接输入法
最简单的建立矩阵的方法是从键盘直接输入矩阵的元素,输入的方法按照上面的规则。建立向量的时候可以利用冒号表达式,冒号表达式可以产生一个行向量,一般格式是: e1:e2:e3,其中e1为初始值,e2为步长,e3为终止值。还可以用linspace函数产生行向量,其调用格式为:linspace(a,b,n) ,其中a和b是生成向量的第一个和最后一个元素,n是元素总数。
2、利用MATLAB函数创建矩阵
基本矩阵函数如下:
(1) ones()函数:产生全为1的矩阵,ones(n):产生n*n维的全1矩阵,ones(m,n):产生m*n维的全1矩阵;
(2) zeros()函数:产生全为0的矩阵;
(3) rand()函数:产生在(0,1)区间均匀分布的随机阵;
(4) eye()函数:产生单位阵;
(5) randn()函数:产生均值为0,方差为1的标准正态分布随机矩阵。
3、利用文件建立矩阵
当矩阵尺寸较大或为经常使用的数据矩阵,则可以将此矩阵保存为文件,在需要时直接将文件利用load命令调入工作环境中使用即可。同时可以利用命令reshape对调入的矩阵进行重排。reshape(A,m,n),它在矩阵总元素保持不变的前提下,将矩阵A重新排成m*n的二维矩阵。
二、矩阵的简单操作
1.获取矩阵元素
可以通过下标(行列索引)引用矩阵的元素,如 Matrix(m,n)。
也可以采用矩阵元素的序号来引用矩阵元素。
矩阵元素的序号就是相应元素在内存中的排列顺序。
在MATLAB中,矩阵元素按列存储。
序号(Index)与下标(Subscript )是一一对应的,以m*n矩阵A为例,矩阵元素A(i,j)的序号为(j-1)*m+i。
其相互转换关系也可利用sub2ind和ind2sub函数求得。
2.矩阵拆分
利用冒号表达式获得子矩阵:
(1) A(:,j)表示取A矩阵的第j列全部元素;A(i,:)表示A矩阵第i行的全部元素;A(i,j)表示取A矩阵第i行、第j列的元素。
(2) A(i:i+m,:)表示取A矩阵第i~i+m行的全部元素;A(:,k:k+m)表示取A矩阵第k~k+m列的全部元素,A(i:i+m,k:k+m)表示取A矩阵第i~i+m行内,并在第k~k+m列中的所有元素。此外,还可利用一般向量和end运算符来表示矩阵下标,从而获得子矩阵。end表示某一维的末尾元素下标。
利用空矩阵删除矩阵的元素:
在MATLAB中,定义[]为空矩阵。给变量X赋空矩阵的语句为X=[]。注意,X=[]与clear X不同,clear是将X从工作空间中删除,而空矩阵则存在于工作空间中,只是维数为0。
3、特殊矩阵
(1) 魔方矩阵魔方矩阵有一个有趣的性质,其每行、每列及两条对角线上的元素和都相等。对于n阶魔方阵,其元素由1,2,3,…,n2共n2个整数组成。MATLAB提供了求魔方矩阵的函数magic(n),其功能是生成一个n阶魔方阵。
(2) 范得蒙矩阵范得蒙(Vandermonde)矩阵最后一列全为1,倒数第二列为一个指定的向量,其他各列是其后列与倒数第二列的点乘积。可以用一个指定向量生成一个范得蒙矩阵。在MATLAB中,函数vander(V)生成以向量V为基础向量的范得蒙矩阵。
(3) 希尔伯特矩阵在MATLAB中,生成希尔伯特矩阵的函数是hilb(n)。使用一般方法求逆会因为原始数据的微小扰动而产生不可靠的计算结果。MATLAB中,有一个专门求希尔伯特矩阵的逆的函数invhilb(n),其功能是求n阶的希尔伯特矩阵的逆矩阵。
(4) 托普利兹矩阵托普利兹(Toeplitz)矩阵除第一行第一列外,其他每个元素都与左上角的元素相同。生成托普利兹矩阵的函数是toeplitz(x,y),它生成一个以x为第一列,y为第一行的托普利兹矩阵。这里x, y均为向量,两者不必等长。toeplitz(x)用向量x生成一个对称的托普利兹矩阵。
(5) 伴随矩阵 MATLAB生成伴随矩阵的函数是compan(p),其中p是一个多项式的系数向量,高次幂系数排在前,低次幂排在后。
(6) 帕斯卡矩阵我们知道,二次项(x+y)n展开后的系数随n的增大组成一个三角形表,称为杨辉三角形。由杨辉三角形表组成的矩阵称为帕斯卡(Pascal)矩阵。函数pascal(n)生成一个n阶帕斯卡矩阵。
三、矩阵的运算
1、算术运算
MATLAB的基本算术运算有:+(加)、-(减)、*(乘)、/(右除)、\(左除)、^(乘方)、’(转置)。运算是在矩阵意义下进行的,单个数据的算术运算只是一种特例。
(1) 矩阵加减运算假定有两个矩阵A和B,则可以由A+B和A-B实现矩阵的加减运算。运算规则是:若A和B矩阵的维数相同,则可以执行矩阵的加减运算,A和B矩阵的相应元素相加减。如果A与B的维数不相同,则MATLAB将给出错误信息,提示用户两个矩阵的维数不匹配。
(2) 矩阵乘法 假定有两个矩阵A和B,若A为m*n矩阵,B为n*p矩阵,则C=A*B为m*p矩阵。
(3) 矩阵除法在MATLAB中,有两种矩阵除法运算:\和/,分别表示左除和右除。如果A矩阵是非奇异方阵,则A\B和B/A运算可以实现。A\B等效于A的逆左乘B矩阵,也就是inv(A)*B,而B/A等效于A矩阵的逆右乘B矩阵,也就是B*inv(A)。对于含有标量的运算,两种除法运算的结果相同。对于矩阵来说,左除和右除表示两种不同的除数矩阵和被除数矩阵的关系,一般A\B≠B/A。
(4) 矩阵的乘方 一个矩阵的乘方运算可以表示成A^x,要求A为方阵,x为标量。
(5) 矩阵的转置 对实数矩阵进行行列互换,对复数矩阵,共轭转置,特殊的,操作符.’共轭不转置(见点运算);
(6) 点运算在MATLAB中,有一种特殊的运算,因为其运算符是在有关算术运算符前面加点,所以叫点运算。点运算符有.*、./、.\和.^。两矩阵进行点运算是指它们的对应元素进行相关运算,要求两矩阵的维参数相同。
2、关系运算
MATLAB提供了6种关系运算符:&(小于)、&=(小于或等于)、&(大于)、&=(大于或等于)、==(等于)、~=(不等于)。关系运算符的运算法则为:
(1) 当两个比较量是标量时,直接比较两数的大小。若关系成立,关系表达式结果为1,否则为0;
(2) 当参与比较的量是两个维数相同的矩阵时,比较是对两矩阵相同位置的元素按标量关系运算规则逐个进行,并给出元素比较结果。最终的关系运算的结果是一个维数与原矩阵相同的矩阵,它的元素由0或1组成;
(3) 当参与比较的一个是标量,而另一个是矩阵时,则把标量与矩阵的每一个元素按标量关系运算规则逐个比较,并给出元素比较结果。最终的关系运算的结果是一个维数与原矩阵相同的矩阵,它的元素由0或1组成。
3、逻辑运算
MATLAB提供了3种逻辑运算符:&(与)、|(或)和~(非)。 逻辑运算的运算法则为:
(1) 在逻辑运算中,确认非零元素为真,用1表示,零元素为假,用0表示;
(2) 设参与逻辑运算的是两个标量a和b,那么,a&b a,b全为非零时,运算结果为1,否则为0。 a|b a,b中只要有一个非零,运算结果为1。~a 当a是零时,运算结果为1;当a非零时,运算结果为0。
(3) 若参与逻辑运算的是两个同维矩阵,那么运算将对矩阵相同位置上的元素按标量规则逐个进行。最终运算结果是一个与原矩阵同维的矩阵,其元素由1或0组成;
(4) 若参与逻辑运算的一个是标量,一个是矩阵,那么运算将在标量与矩阵中的每个元素之间按标量规则逐个进行。最终运算结果是一个与矩阵同维的矩阵,其元素由1或0组成;
(5) 逻辑非是单目运算符,也服从矩阵运算规则;
(6) 在算术、关系、逻辑运算中,算术运算优先级最高,逻辑运算优先级最低。
四、矩阵分析
(1) 对角阵只有对角线上有非0元素的矩阵称为对角矩阵,对角线上的元素相等的对角矩阵称为数量矩阵,对角线上的元素都为1的对角矩阵称为单位矩阵。
(1) 提取矩阵的对角线元素设A为m*n矩阵,diag(A)函数用于提取矩阵A主对角线元素,产生一个具有min(m,n)个元素的列向量。diag(A)函数还有一种形式diag(A,k),其功能是提取第k条对角线的元素。
(2) 构造对角矩阵设V为具有m个元素的向量,diag(V)将产生一个m*m对角矩阵,其主对角线元素即为向量V的元素。diag(V)函数也有另一种形式diag(V,k),其功能是产生一个n*n(n=m+k)对角阵,其第m条对角线的元素即为向量V的元素。
三角阵又进一步分为上三角阵和下三角阵,所谓上三角阵,即矩阵的对角线以下的元素全为0的一种矩阵,而下三角阵则是对角线以上的元素全为0的一种矩阵。
(1) 上三角矩阵 求矩阵A的上三角阵的MATLAB函数是triu(A)。 triu(A)函数也有另一种形式triu(A,k),其功能是求矩阵A的第k条对角线以上的元素。
(2) 下三角矩阵在MATLAB中,提取矩阵A的下三角矩阵的函数是tril(A)和tril(A,k),其用法与提取上三角矩阵的函数triu(A)和triu(A,k)完全相同。
3、矩阵的转置与旋转
(1) 矩阵的转置 转置运算符是单撇号(’)。
(2) 矩阵的旋转 利用函数rot90(A,k)将矩阵A旋转90o的k倍,当k为1时可省略。
4、矩阵的翻转
对矩阵实施左右翻转是将原矩阵的第一列和最后一列调换,第二列和倒数第二列调换,…,依次类推。矩阵A实施左右翻转的函数是fliplr(A),对矩阵A实施上下翻转的函数是flipud(A)。
5、矩阵的逆与伪逆
(1) 矩阵的逆 对于一个方阵A,如果存在一个与其同阶的方阵B,使得:AB=BA=I (I为单位矩阵) 则称B为A的逆矩阵,当然,A也是B的逆矩阵。求方阵A的逆矩阵可调用函数inv(A)。
(2) 矩阵的伪逆如果矩阵A不是一个方阵,或者A是一个非满秩的方阵时,矩阵A没有逆矩阵,但可以找到一个与A的转置矩阵A’同型的矩阵B,使得:ABA=A,BAB=B 此时称矩阵B为矩阵A的伪逆,也称为广义逆矩阵。在MATLAB中,求一个矩阵伪逆的函数是pinv(A)。
6、方阵的行列式
把一个方阵看作一个行列式,并对其按行列式的规则求值,这个值就称为矩阵所对应的行列式的值。在MATLAB中,求方阵A所对应的行列式的值的函数是det(A)。
7、矩阵的秩与迹
(1) 矩阵的秩 矩阵线性无关的行数与列数称为矩阵的秩。在MATLAB中,求矩阵秩的函数是rank(A)。
(2) 矩阵的迹矩阵的迹等于矩阵的对角线元素之和,也等于矩阵的特征值之和。在MATLAB中,求矩阵的迹的函数是trace(A)。
8、向量和矩阵的范数
矩阵或向量的范数用来度量矩阵或向量在某种意义下的长度。范数有多种方法定义,其定义不同,范数值也就不同。
(1) 向量的3种常用范数及其计算函数 在MATLAB中,求向量范数的函数为:
a、norm(V)或norm(V,2):计算向量V的2-范数;
b、norm(V,1):计算向量V的1-范数;
c、norm(V,inf):计算向量V的∞-范数。
(2) 矩阵的范数及其计算函数 MATLAB提供了求3种矩阵范数的函数,其函数调用格式与求向量的范数的函数完全相同。
(3) 矩阵的条件数 在MATLAB中,计算矩阵A的3种条件数的函数是:
a、cond(A,1) 计算A的1-范数下的条件数;
b、cond(A)或cond(A,2) 计算A的2-范数数下的条件数;
c、cond(A,inf) 计算A的 ∞-范数下的条件数。
9、 矩阵的特征值与特征向量
在MATLAB中,计算矩阵A的特征值和特征向量的函数是eig(A),常用的调用格式有3种:
(1) E=eig(A):求矩阵A的全部特征值,构成向量E。
(2) [V,D]=eig(A):求矩阵A的全部特征值,构成对角阵D,并求A的特征向量构成V的列向量。
(3) [V,D]=eig(A,’nobalance’):与第2种格式类似,但第2种格式中先对A作相似变换后求矩阵A的特征值和特征向量,而格式3直接求矩阵A的特征值和特征向量。
五、字符串
在MATLAB中,字符串是用单撇号括起来的字符序列。MATLAB将字符串当作一个行向量,每个元素对应一个字符,其标识方法和数值向量相同。也可以建立多行字符串矩阵。字符串是以ASCII码形式存储的。abs和double函数都可以用来获取字符串矩阵所对应的ASCII码数值矩阵。相反,char函数可以把ASCII码矩阵转换为字符串矩阵。与字符串有关的另一个重要函数是eval,其调用格式为: eval_r(t) 其中t为字符串。它的作用是把字符串的内容作为对应的MATLAB语句来执行。
查看矩阵非零元素的分布spy(A);
第二部分 矩阵的应用
一、稀疏矩阵
对于一个 n 阶矩阵,通常需要 n2 的存储空间,当 n 很大时,进行矩阵运算时会占用大量的内存空间和运算时间。在许多实际问题中遇到的大规模矩阵中通常含有大量0元素,这样的矩阵称为稀疏矩阵。Matlab支持稀疏矩阵,只存储矩阵的非零元素。由于不存储那些”0″元素,也不对它们进行操作,从而节省内存空间和计算时间,其计算的复杂性和代价仅仅取决于稀疏矩阵的非零元素的个数,这在矩阵的存储空间和计算时间上都有很大的优点。
矩阵的密度定义为矩阵中非零元素的个数除以矩阵中总的元素个数。对于低密度的矩阵,采用稀疏方式存储是一种很好的选择。
1、稀疏矩阵的创建
(1) 将完全存储方式转化为稀疏存储方式函数A=sparse(S)将矩阵S转化为稀疏存储方式的矩阵A。当矩阵S是稀疏存储方式时,则函数调用相当于A=S。 sparse函数还有其他一些调用格式: sparse(m,n):生成一个m*n的所有元素都是0的稀疏矩阵。 sparse(u,v,S)--:u,v,S是3个等长的向量。S是要建立的稀疏矩阵的非0元素,u(i)、v(i)分别是S(i)的行和列下标,该函数建立一个max(u)行、max(v)列并以S为稀疏元素的稀疏矩阵。此外,还有一些和稀疏矩阵操作有关的函数。full(A):返回和稀疏存储矩阵A对应的完全存储方式矩阵。
(2) 直接创建稀疏矩阵 S=sparse(i,j,s,m,n),其中i 和j 分别是矩阵非零元素的行和列指标向量,s 是非零元素值向量,m,n 分别是矩阵的行数和列数。
(3) 从文件中创建稀疏矩阵利用load和spconvert函数可以从包含一系列下标和非零元素的文本文件中输入稀疏矩阵。例:设文本文件 T.txt 中有三列内容,第一列是一些行下标,第二列是列下标,第三列是非零元素值。load T.txt S=spconvert(T)。
(4) 稀疏带状矩阵的创建 S=spdiags(B,d,m,n) 其中m 和n 分别是矩阵的行数和列数;d是长度为p的整数向量,它指定矩阵S的对角线位置;B是全元素矩阵,用来给定S对角线位置上的元素,行数为min(m,n),列数为p 。
(5) 其它稀疏矩阵创建函数
S=speye(m,n)
S=speye(size(A)) % has the same size as A
S=buchy % 一个内置的稀疏矩阵(邻接矩阵)
2、稀疏矩阵的运算
稀疏存储矩阵只是矩阵的存储方式不同,它的运算规则与普通矩阵是一样的,可以直接参与运算。所以,Matlab中对满矩阵的运算和函数同样可用在稀疏矩阵中。结果是稀疏矩阵还是满矩阵,取决于运算符或者函数。当参与运算的对象不全是稀疏存储矩阵时,所得结果一般是完全存储形式。
(1) 非零元素信息
nnz(S) % 返回非零元素的个数
nonzeros(S) % 返回列向量,包含所有的非零元素
nzmax(S) % 返回分配给稀疏矩阵中非零项的总的存储空间
(2) 查看稀疏矩阵的形状 spy(S)
(3) find函数与稀疏矩阵
[i,j,s]=find(S)
[i,j]=find(S)
返回 S 中所有非零元素的下标和数值,S 可以是稀疏矩阵或满矩阵。
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:228907次
积分:3261
积分:3261
排名:第5424名
原创:103篇
转载:10篇
评论:19条的海词问答和网友补充:
相关词典网站:求救!matlab max函数告诉我说 Indexing cannot yield multiple results._百度知道
求救!matlab max函数告诉我说 Indexing cannot yield multiple results.
grnn=30,j)=w*V(i;else:)),j)&);mostbestx=vmax=0.8;
fit(i)=fitness(X(i;c2=2;2)'[
V(i;fitmost(i);end,mostbestx]=max(fit),j))+c2*rand()*(mostbestx(j)-X(i;V=0.6;
fitmost(i)=fit(i):
for j=1,:)=X(i;
for i=1:),j)=vmax.8*rand(
mostmax=max:for i=1,;gnrtn=gnrtn+1:));
if max&[mostmaxvrtnn=1;c1=2;
if fit(i)&gt,bestx]=max(fit);
gnrtn=1,j));
fitmost=if gnrtn==1;
if V(i,1);
else:x'gnrtnmax=100,j)+c1*rand()*(p(i,:grnn:mostbestx=bestx:X=X+V:for i=1;
fit(i)=fitness(X(i;for i=1;p(i;
for j=1,vrtnn);fit=rand(
if gnrtn==1.1*(1-x+2*x^2)*exp(-x^2/
end,;for k=1;
for i=1,j)-X(i;p=X;2;
fitness=inline(&#39,vrtnn);w=0;,'
X=-5+10*rand(grnn
提问者采纳
max本身是函数,不能作为变量名称出现程序里。
提问者评价
谢谢谢谢!我太笨了。。
其他类似问题
为您推荐:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁Error and Warning Messages (MATLAB Compiler)
MATLAB Compiler
Compile-Time Errors
Error: An error occurred while shelling out to mex/mbuild (error code = errorno). Unable to build executable (specify the -v option for more information). &&The Compiler reports this error if mbuild or mex generates an error.
Error: An error occurred writing to file "filename": reason. &&The file could not be written. The reason is provided by the operating system. For example, you may not have sufficient disk space available to write the file.
Error: Cannot recompile M-file "filename" because it is already in library "libraryname". &&A procedure already exists in a library that has the same name as the M-file that is being compiled. For example:
mcc -x sin.m % Incorrect
Error: Cannot write file "filename" because MCC has already created a file with that name, or a file with that name was specified as a command line argument. &&The Compiler has been instructed to generate two files with the same name. For example:
mcc -W lib:liba liba -t % Incorrect
Error: Could not check out a Compiler license. &&No additional Compiler licenses are available for your workgroup.
Error: Could not find license file "filename". &&(Windows only) The license.dat file could not be found in &MATLAB&\bin.
Error: Could not run mbuild. The MATLAB C/C++ Math Library must be installed in order to build stand-alone applications. &&Install the MATLAB C/C++ Math Library.
Error: File: "filename" not found. &&A specified file could not be found on the path. Verify that the file exists and that the path includes the file's location. You can use the -I option to add a directory to the search path
Error: File: "filename" is a script M-file which cannot be compiled with the current Compiler. &&The MATLAB Compiler cannot compile script M-files. To learn how to convert script M-files to function M-files, see .
Error: File: filename Line: # Column: # != is not a MATLAB operator. Use ~= instead. &&Use the MATLAB relational operator ~= (not equal).
Error: File: filename Line: # Column: # () indexing must appear last in an index expression. &&If you use ordinary array indexing () to index into an expression, it must be last in the index expression. For example, you can use X(1).value and X{2}(1), but you cannot use X.value(1) or X(1){2}.
Error: File: filename Line: # Column: # A CONTINUE may only be used within a FOR or WHILE loop. &&Use Continue to pass control to the next iteration of a for or while loop.
Error: File: filename Line: # Column: # A function declaration cannot appear within a script M-file. &&There is a function declaration in the file to be compiled, but it is not at the beginning of the file. Scripts cannot have any f function M-files must start with a function.
Error: File: filename Line: # Column: # Assignment statements cannot produce a result. &&An assignment statement cannot be used in a place where an expression, but not a statement, is expected. In particular, this message often identifies errors where an assignment was used, but an equality test was intended. For example:
if x == y, z = end % Correct
if x = y, z = end % Incorrect
Error: File: filename Line: # Column: # A variable cannot be made storageclass1 after being used as a storageclass2. &&You cannot change a variable's storage class (global/local/persistent). Even though MATLAB allows this type of change in scope, the Compiler does not.
Error: File: filename Line: # Column: # An array for multiple LHS assignment must be a vector. &&If the left-hand side of a statement is a multiple assignment, the list of left-hand side variables must be a vector. For example:
[p1, p2, p3] = myfunc(a)% Correct
[p1; p2; p3] = myfunc(a)% Incorrect
Error: File: filename Line: # Column: # An array for multiple LHS assignment cannot be empty. &&If the left-hand side of a statement is a multiple assignment, the list of left-hand side variables cannot be empty. For example:
[p1, p2, p3] = myfunc(a)% Correct
[ ] = myfunc(a)% Incorrect
Error: File: filename Line: # Column: # An array for multiple LHS assignment cannot contain token. &&If the left-hand side of a statement is a multiple assignment, the vector cannot contain this token. For example, you cannot assign to constants.
[p1] = myfunc(a)% Correct
[3] = myfunc(a)% Incorrect
Error: File: filename Line: # Column: # Expected a variable, function, or constant, found "string". &&There is a syntax error in the specified line. See the online
Error: File: filename Line: # Column: # Expected one of , ; % or EOL, got "string". &&There is a syntax error in the specified line. See the online
Error: File: filename Line: # Column: # Functions cannot be indexed using {} or . indexing. &&You cannot use the cell array constructor, {}, or the structure field access operator, ., to index into a function.
Error: File: filename Line: # Column: # Indexing expressions cannot return multiple results. &&There is an assignment in which the left-hand side takes multiple values, but the right-hand side is not a function call but rather a structure access. For example:
[x, y] = f(z) % Correct
[x, y] = f.z % Incorrect
Error: File: filename Line: # Column: # Invalid multiple left-hand-side assignment. &&For example, you try to assign to constants
[] = sin(1);% Incorrect
Error: File: filename Line: # Column: # MATLAB assignment cannot be nested. &&You cannot use a syntax such as x = y = 2. Use y = 2, x = y instead.
Error: File: filename Line: # Column: # Missing operator, comma, or semicolon. &&There is a syntax error in the file. Syntactically, an operator, a comma, or a semicolon is expected, but is missing. For example:
if x == y, z = end % Correct
if x == y, z = w end % Incorrect
Error: File: filename Line: # Column: # Missing variable or function. &&An illegal name was used for a variable or function. For example:
% Incorrect
Error: File: filename Line: # Column: # Only functions can return multiple values. &&In this example, foo must be a function, it cannot be a variable.
Error: File: filename Line: # Column: # "string1" expected, "string2" found. &&There is a syntax error in the specified line. See the online
pages accessible from the Help browser.
Error: File: filename Line: # Column: # The end operator can only be used within an array index expression. &&You can use the end operator in an array index expression such as sum(A(:, end)). You cannot use the end operator outside of such an expression, for example: y = 1 + end.
Error: File: filename Line: # Column: # The name "parametername" occurs twice as an input parameter. &&The variable names specified on the function declaration line must be unique. For example:
function foo(bar1, bar2)% Correct
function foo(bar, bar)% Incorrect
Error: File: filename Line: # Column: # The name "parametername" occurs twice as an output parameter. &&The variable names specified on the function declaration line must be unique. For example:
function [bar1, bar2] = foo% Correct
function [bar, bar] = foo% Incorrect
Error: File: filename Line: # Column: # The "operatorname" operator may only produce a single output. &&The primitive operator produces only a single output. For example:
x = 1:10; % Correct
[x, y] = 1:10; % Incorrect
Error: File: filename Line: # Column: # The PERSISTENT declaration must precede any use of the variable variablename. &&In the text of the function, there is a reference to the variable before the persistent declaration.
Error: File: filename Line: # Column: # The single colon operator (:) can only be used within an array index expression. &&You can only use the : operator by itself as an array index. For example: A(:) = 5; is okay, but y = :; is not.
Error: File: filename Line: # Column: # The variable variablename was mentioned more than once as an input. &&The argument list has a repeated variable. For example:
function y = myfun(x, x) % Incorrect
Error: File: filename Line: # Column: # The variable variablename was mentioned more than once as an output. &&The return value vector has a repeated variable. For example:
function [x, x] = myfun(y) % Incorrect
Error: File: filename Line: # Column: # This statement is incomplete. Variable arguments cannot be made global or persistent. &&The variables varargin and varargout are not like other variables. They cannot be declared either global or persistent. For example:
global varargin % Incorrect
Error: File: filename Line: # Column: # Variable argument (varargin) must be last in input argument list. &&The function call must specify the required arguments first followed by varargin. For example:
function [out1, out2] = example1(a, b, varargin)% Correct
function [out1, out2] = example1(a, varargin, b)% Incorrect
Error: File: filename Line: # Column: # Variable argument (varargout) must be last in output argument list. &&The function call must specify the required arguments first followed by varargout. For example:
function [i, j, varargout]= ex2(x1, y1, x2, y2, val)% Correct
function [i, varargout, j]= ex2(x1, y1, x2, y2, val)% Incorrect
Error: File: filename Line: # Column: # variablename has been declared both as GLOBAL and PERSISTENT. &&Declare variables as either global or persistent.
Error: Found illegal whitespace character in command line option: "string". The strings on the left and right side of the space should be separate arguments to MCC. &&For example:
mcc('-A', 'none')% Correct
mcc('-A none')% Incorrect
Error: Improper usage of option -optionname. Type "mcc -?" for usage information. &&You have incorrectly used a Compiler option. For more information about Compiler options, see
or type mcc -? at the command prompt.
Error: "languagename" is not a known language. &&The dialect option was given a language argument for which there is no support yet. For example:
mcc -m -D japanese sample.m % Correct
mcc -m -D german sample.m % Incorrect
Error: libraryname library not found. &&MATLAB has been installed incorrectly.
Error: MEX-File "mexfilename" cannot be compiled into P-Code. &&Only M-files can be compiled into P- MEX-files cannot be compiled into P-code.
Error: No source files were specified (-? for help). &&You must provide the Compiler with the name of the source file(s) to compile.
Error: On UNIX, the name of an MLIB-file must begin with the letters "lib". 'filename' does not adhere to this rule. &&The mlib file specified on the command line does not start with the letters "lib" and the file being compiled uses procedures in that library.
Error: "optionname" is not a valid -option option argument. &&You must use an argument that corresponds to the option. For example:
mcc -L Cpp ...% Correct
mcc -L COBOL ...% Incorrect
Error: Out of memory. &&Typically, this message occurs because the Compiler requests a larger segment of memory from the operating system than is currently available. Adding additional memory to your system could alleviate this problem.
Error: Previous warning treated as error. &&When you use the -w error option, this error displays immediately after a warning message.
Error: The argument after the -option option must contain a colon. &&The format for this argument requires a colon. For more information, see
or type mcc -? at the command prompt.
Error: The environment variable MATLAB must be set to the MATLAB root directory. &&On UNIX, the MATLAB and LM_LICENSE_FILE variables must be set. The mcc shell script does this automatically when it is called the first time.
Error: The file filename cannot be written. &&When generating an mlib file, the Compiler cannot write out the mlib file.
Error: The license manager failed to initialize (error code is errornumber). &&You do not have a valid Compiler license or no additional Compiler licenses are available.
Error: The option -option is invalid in modename mode (specify -? for help). &&The specified option is not available.
Error: The option -option must be immediately followed by whitespace (e.g. "proper_example_usage"). &&These options require additional information, so they cannot be combined.
-A, -B, -d, -f, -F, -I, -L, -M, -o, -T, -u, -W, -x, -y, -Y, -z
For example, you can use mcc -vc, but you cannot use mcc&-Ac&annotation:all.
Error: The options specified will not generate any output files.Please use one of the following options to generate an executable output file:&&&&-x (generates a MEX-file executable using C)&&&&-m (generates a stand-alone executable using C)&&&&-p (generates a stand-alone executable using C++)&&&&-S (generates a Simulink MEX S-function using C)-B sgl (generates a stand-alone graphics library executable using C (requires the SGL))-B sglcpp (generates a stand-alone graphics library executable using C++ (requires the SGL))-B pcode (generates a MATLAB P-code file)&&&&Or type mcc -? for more usage information. &&Use one of these options or another option that generates an output file(s). See
or type mcc -? at the command prompt for more information.
Error: The specified file "filename" cannot be read. &&There is a problem with your specified file. For example, the file is not readable because there is no read permission.
Error: The -option option cannot be combined with other options. &&The -V2.0 option must appear separate from other options on the command line. For example:
mcc -V2.0 -L Cpp ...% Correct
mcc -V2.0L Cpp ...% Incorrect
Error: The -optionname option requires an argument (e.g. "proper_example_usage"). &&You have incorrectly used a Compiler option. For more information about Compiler options, see
or type mcc -? at the command prompt.
Error: This version of MCC does not support the creation of C++ MEX code. &&You cannot create C++ MEX functions with the current Compiler.
Error: Unable to open file "filename":&string&. &&There is a problem with your specified file. For example, there is no write permission to the output directory, or the disk is full.
Error: Unable to set license linger interval (error code is errornumber). &&A license manager failure has occurred. Contact Technical Support at The MathWorks with the full text of the error message.
Error: Uninterpretable number of inputs set on command line "commandline". &&When generating a Simulink S-function, the inputs specified on the command line was not a number. For example:
mcc -S -u 2 sample.m % Correct
mcc -S -u a sample.m % Incorrect
Error: Uninterpretable number of outputs set on command line "commandline". &&When generating a Simulink S-function, the outputs specified on the command line was not a number. For example:
mcc -S -y 2 sample.m % Correct
mcc -S -y a sample.m % Incorrect
Error: Uninterpretable width set on command line "commandline". &&The argument to the page width option was not interpretable as a number.
Error: Unknown annotation option: optionname. &&An invalid string was specified after the -A option. For a complete list of the valid annotation options, see
or type mcc -? at the command prompt.
Error: Unknown typesetting option: optionname. &&The valid typesetting options available with -F are expression-indent:n, list, page-width, and statement-indent:n.
Error: Unknown warning enable/disable string: warningstring. &&-w enable:, -w disable:, and -w error: require you to use one of the warning string identifiers listed in the .
Error: Unrecognized option: -option. &&The option is not one of the valid options for this version of the Compiler. See
for a complete list of valid options for MATLAB Compiler 3.0 or type mcc&-? at the command prompt.
Error: Use "-V2.0" to specify desired version. &&You specified -V without a version number. You must use -V2.0 if you specify a version number.
Error: versionnumber is not a valid version number. Use "-V2.0". &&If you specify a Compiler version number, it must be -V2.0. The default is -V2.0.
&&Error and Warning Messages&Warning Messages&}

我要回帖

更多关于 app indexing 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信