Matlab基础复习(1)

来源:互联网 发布:同性题材网络剧泰国 编辑:程序博客网 时间:2024/05/27 00:56

Matlab 变量规则 :

1) 变量名区分大小写

2)变量名小于63位

3)变量名以字母开头


Matlab 常量表 :

i, j : 虚数单位

pi: 圆周率

eps: 浮点运算相对精度

NaN: Not-a-Number 不定值

Realmin: 最小的正浮点数, 2^(-1022)

Realmax: 最大的浮点数, 2^1023

Inf: 无穷大


字符串: 在Matlab中, 字符串都用单引号设定后输入或赋值


字符数组: e.g. SC=char(''a,'b','c');


在Matlab中, 字符串和字符数组基本上的等价的


数值数组与字符串的互相转换可以由double与cellstr实现


数值数组与字符串之间的转换函数表:

num2str

int2str

mat2str

str2num

sprintf: 将格式数据写为字符串

sscanf: 在格式控制下读字符串


字符串操作表:

strcat: 连接字符串

strvcat: 垂直连接字符串

strcmp:  TF = strcmp(S1,S2) compares the strings S1 and S2 and returns logical 1 (true) if they are identical, and returns logical 0 (false) otherwise.

strncmp: 比较前n个字符串

findstr:  K = findstr(S1,S2) returns the starting indices of any occurrences  of the shorter of the two strings in the longer.

 strmatch:

  I = strmatch(STR, STRARRAY) looks through the rows of the character
    array or cell array of strings STRARRAY to find strings that begin
    with the string contained in STR, and returns the matching row indices.
    Any trailing space characters in STR or STRARRAY are ignored when
    matching. strmatch is fastest when STRARRAY is a character array. 

strrep:

0 0