matlab字符串、单元数组和结构
MATLAB 7 简明教程
清华大学出版社
判断字符串是否相等 有两个函数可以用来 判断两个输入的字符 串是否相等。– strcmp函数:比较两个 字符串是否相等,当相 等时,系统将返回值1, 不相等时,返回值0; – strncmp函数:比较两 个输入字符串的前几个 字符是否相等,当相等 时,系统将返回值1, 不相等时,返回值0。 >> words1=‘人民文学'; >> words2=‘人民的同志'; >> N=strcmp(words1,words2) N=
0 >> Y=strncmp(words1,words2,3) Y= 0 >> x=strncmp(words1,words2,1) x= 1 >>
2011-4-20
第5章 字符串、单元数组和结构