matlab处理字符串(空格替换)

来源:互联网 发布:lol欧服账号淘宝 编辑:程序博客网 时间:2024/06/14 13:29

举个简单的例子来说比较方便,比如我新建一个txt文档内容是Find the starting indices of the pattern string.我把它放在Matlab的当前工作路径上,文件名字为001.txt,我想把其中的空格变成逗号.那么可以仿照如下的方式来进行:

1
2
str=importdata('001.txt');
a=strrep(str,'  ',',')

输出结果

1
a='Find,the,starting,indices,of,the,pattern,string.'