MATLAB操作员和特殊角色
此页面包含所有MATLAB的全面列表®操作员,符号和特殊字符。
算术操作员
Relational Operators
逻辑操作员
Symbol | 角色 | 更多信息 |
---|---|---|
和 |
Find logical AND |
and |
| |
找到逻辑或 |
or |
&& |
Find logical AND (with short-circuiting) |
逻辑运算符:短路&& || |
|| |
找到逻辑或(with short-circuiting) |
|
〜 |
找不到逻辑 |
不是 |
特殊字符
@ |
name:一个t symbol 用途:
描述: 这 例子 创建一个命名函数的函数句柄: fhandle = @myfun 为匿名函数创建函数句柄: fhandle = @(x,y)x。^2 + y。^2; 致电 disp@mysuper(obj) 使用要构造的对象从子类调用超类构造函数: obj = obj@mysuper(arg1,arg2,。。。) 更多信息: |
。 |
name:期间或点 用途:
描述: 这period character separates the integral and fractional parts of a number, such as 例子 小数点: 102.5543 元素操作: A.*B A.^2 结构字段访问: mystruct.f1 对象属性规范: myobj.propertyname 更多信息 |
。。。 |
name:点点或省略号 用途:Line continuation 描述:Three or more periods at the end of a line continues the current command on the next line. If three or more periods occur before the end of a line, then MATLAB ignores the rest of the line and continues to the next line. This effectively makes a comment out of anything on the current line that follows the three periods. 笔记 Matlab将省略号解释为空间特征。因此,多行命令必须有效作为单行,其省略号被空间字符代替。 例子 继续在下一行上进行函数调用: sprintf(['这current value '。。。'%s是%d'],vname,value) 将角色向量分解在多条线上,并将线路连接在一起: s = ['如果在'之前发生三个或以上的时间。。。'结尾of a line, then the rest of that line is '。。。“被忽略,Matlab继续进入下一行”这是给予的 要在多行命令中评论一行,请使用 y = 1 +。。。2 +。。。%3 +...4; However, this code runs properly since the third line does not produce a gap in the command: y = 1 +。。。2 +。。。。。。3 +...4; 更多信息 |
,,,, |
name:Comma 用途:Separator 描述:Use commas to separate row elements in an array, array subscripts, function input and output arguments, and commands entered on the same line. 例子 单独的行元素以创建一个数组: 一个=[12,13; 14,15] Separate subscripts: A(1,2) 功能调用中的单独输入和输出参数: [Y,I] = max(A,[],2) Separate multiple commands on the same line (showing output): 图,情节(sin(-pi:0.1:pi)),网格on
更多信息 |
: |
name: 冒号 用途:
描述:使用结肠操作员创建定期间隔的向量,索引到数组,并定义一个的边界 例子 创建一个向量: x = 1:10 创建一个向量增加3: x = 1:3:19 将矩阵重塑为列向量: 一个(:) 分配新元素而不更改数组的形状: a = rand(3,4);A(:) = 1:12; 在特定维度中索引一系列元素: A(2:5,3) 索引特定维度中的所有元素: A(:,3)
x = 1;为了k = 1:25 x = x + x^2;结尾 更多信息 |
; |
name:Semicolon 用途:
描述:使用分号在数组创建命令中分离行,或抑制代码行的输出显示。 例子 单独的行创建一个数组: 一个=[12,13; 14,15] Suppress code output: y = max(a); 单个行上的单独多个命令(抑制输出): a = 12.5;B = 42.7,C = 1.25;B = 42.7000 更多信息 |
( ) |
name: 括号 用途:
描述:Use parentheses to specify precedence of operations, enclose function input arguments, and index into an array. 例子 行动的优先级: (A B C D 功能参数外壳: plot(X,Y,'r*')c =联合(a,b)
索引: A(3,:) a(1,2)a(1:5,1) 更多信息 |
[ ] |
name: 方括号 用途:
描述:方括号启用数组构造和串联,创建空矩阵,删除数组元素以及捕获函数返回的值。 例子 Construct a three-element vector: X = [10 12 -3] 向矩阵添加新的底部行: a = rand(3);a = [a;10 20 30] 创建一个空矩阵: 一个=[] 删除矩阵列: A(:,1)= [] Capture three output arguments from a function: [c,ia,ib] =联合(a,b) 更多信息 |
{ } |
name: 大括号 用途:单元阵列分配和内容 描述:使用卷曲括号构造单元格数,或访问单元格数组中特定单元格的内容。 例子 要构造一个单元格数组,将数组的所有元素包装在卷曲括号中: c = {[2.6 4.7 3.9],rand(8)*6,'C。柯立芝'}
Index to a specific cell array element by enclosing all indices in curly braces: 一个=C{4,7,2} 更多信息 |
% |
name: 百分 用途:
描述: 这percent sign is most commonly used to indicate nonexecutable text within the body of a program. This text is normally used to include comments in your code. 某些功能还将百分比符号解释为转换说明符。 2%的迹象, 例子 将注释添加到一个代码块中: %循环的目的是计算% 的价值 ... Use conversion specifier with sprintf('%s =%d',,,,name, value)
更多信息 |
%{%} |
name:百分比卷曲支架 用途:block comments 描述: 这 笔记 With the exception of whitespace characters, the 例子 Enclose any multiline comments with percent followed by an opening or closing brace: %{此例程的目的是计算的价值 ...%} 更多信息 |
呢 |
name:感叹号 用途:操作系统命令 描述:在MATLAB内部执行的操作系统命令之前的感叹点要先于操作系统命令。 not available inMATLABOnline™。 例子 这exclamation point initiates a shell escape function. Such a function is to be performed directly by the operating system: !rmdir oldtests
更多信息 |
? |
name:问号 用途:matlab课程的元类 描述: 这question mark retrieves the 例子 检索类的meta.class对象 ?inputparser 更多信息 |
'' |
name:Single quotes 用途:字符阵列构造函数 描述:Use single quotes to create character vectors that have class 例子 创建一个字符向量: chr ='你好世界'
更多信息 |
“” |
name: 双引号 用途:String constructor 描述:使用双引号创建具有类的字符串标量 例子 创建一个字符串标量: s =“你好世界”
更多信息 |
N/A。 |
name:太空角色 用途:Separator 描述:Use the space character to separate row elements in an array constructor, or the values returned by a function. In these contexts, the space character and comma are equivalent. 例子 单独的行元素以创建一个数组: 这些陈述是等效的a = [12 13;14 15] a = [12,13;14,15]
Separate output arguments in function calls: 这些陈述是等效的[y i] = max(a)[y,i] = max(a)
|
N/A。 |
name:newline字符 用途:Separator 描述:Use the newline character to separate rows in an array construction statement. In that context, the newline character and semicolon are equivalent. 例子 数组创建命令中的单独行: 这些陈述是等效的一个=[12 13 14 15] A = [12 13; 14 15]
|
〜 |
name:tilde 用途:
描述:Use the tilde symbol to represent logical NOT or to suppress specific input or output arguments. 例子 计算矩阵的逻辑: a =眼(3);〜a 确定元素的位置 a = [1 -1;0 1] b = [1 -2;3 2] a〜 = b 仅返回第三个输出值的 [~, ~, iB] =联盟(A, B) 更多信息 |
= |
name:平等标志 用途: 任务 描述:使用平等符号将值分配给变量。语法 笔记 这 例子 Create a matrix 一个=[1 0; -1 0]; B = A; B(1) = 200; |
<& |
name:左角支架和兼而 用途:Specify superclasses 描述:Specify one or more superclasses in a class definition 例子 定义从一个超级类派生的类: ClassDefmy级 Define a class that derives from multiple superclasses: ClassDefMyClass < Superclass1 & Superclass2 & … …结尾 更多信息: |
。? |
name:Dot question mark 用途:指定名称值结构的字段 描述: 使用函数参数验证时,您可以将名称值结构的字段定义为类的所有可写入属性的名称。 例子 指定字段名称 functionf(propArgs)参数propargs结尾%功能代码。。。结尾 更多信息: |
String and Character Formatting
一些特殊字符只能在字符向量或字符串的文本中使用。您可以使用这些特殊字符插入新线路或运输返回,指定文件夹路径等。
使用此表中的特殊字符使用字符向量或字符串指定文件夹路径。
|
name:Slash and Backslash 用途:File or folder path separation 描述:除了用作数学运算符外,斜线和背斜线字符还将路径或文件夹的元素分开。在Microsoft上®Windows®基于系统,斜线和后斜线都具有相同的效果。在开放式unix上®based systems, you must use slash only. 例子 在Windows系统上,您可以使用BackSlash或Slash: dir([matlabroot'\ toolbox \ matlab \ elmat \ shiftdim.m'])dir([Matlabroot'/toolbox/matlab/elmat/shiftdim.m'))) 在UNIX系统上,仅使用前向斜线: dir([matlabroot'/toolbox/matlab/elmat/shiftdim.m')))
|
。。 |
name:点点 用途:父文件夹 描述:连续两个点是指当前文件夹的父。使用此字符来指定相对于当前文件夹的文件夹路径。 例子 要在文件夹树中上升两个级别,然后向下进入 光盘..\..\测试
更多信息 |
* |
name:星号 用途:Wildcard character 描述:除了是矩阵乘法的符号外,星号 通配符通常用于对多个文件或文件夹作用的文件操作。MATLAB与名称中的所有字符完全匹配,除了通配符字符 例子 找到所有以开头的名称的文件 dir('1月_*。垫子')
|
@ |
name:一个t symbol 用途:Class folder indicator 描述:一个n 例子 请参阅类文件夹: \ \@myClass\get.m 更多信息 |
+ |
name:plus 用途:软件包目录指示器 描述:一个 例子 Package folders always begin with the +mypack +mypack/pkfcn.m%包装功能+mypack/@myclass包装中的%类文件夹 更多信息 |
有某些特殊字符,您无法作为普通文本输入。相反,您必须使用唯一的字符序列来表示它们。使用此表中的符号自行格式化字符串和角色向量,或与格式函数(如撰写
,,,,Sprintf
,,,,and错误
。For more information, see格式化文本。
Symbol | Effect on Text |
---|---|
'' |
单引号标记 |
%% |
单个百分比符号 |
\\ |
单个后斜线 |
\一个 |
一个larm |
\ b |
backspace |
\F |
形式饲料 |
\ n |
新队 |
\ r |
Carriage return |
\ t |
水平标签 |
\ v |
垂直选项卡 |
\ xn |
Hexadecimal number, |
\ n |
八达数字, |