用matlab 提取字符串中的数字.
来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/04/28 18:12:01
用matlab 提取字符串中的数字.
用matlab读文件名,出现1005.xls; 1.xls; 100.xls等等这样的字符串,现在想用matlab将其中的数字提出来,成为 1005 1 100.这样的数组,好像可以使用regexp函数,但是具体操作有点不懂
用matlab读文件名,出现1005.xls; 1.xls; 100.xls等等这样的字符串,现在想用matlab将其中的数字提出来,成为 1005 1 100.这样的数组,好像可以使用regexp函数,但是具体操作有点不懂
S = REGEXP(STRING,EXPRESSION)
其中EXPRESSION的取法为:
.Any character
[] Any character contained within the brackets
[^] Any character not contained within the brackets
\w A word character [a-z_A-Z0-9]
\W Not a word character [^a-z_A-Z0-9]
\d A digit [0-9]
\D Not a digit [^0-9]
\s Whitespace [ \t\r\n\f\v]
\S Not whitespace [^ \t\r\n\f\v]
那么你的问题就可以使用下面的代码了
>>a='5000.xls'
a =
5000.xls
>> s=a(regexp(a,'\d'))
s =
5000
这时的s是字符型的,如果你需要数字的话就是用str2num转化一下
祝你学习愉快!
其中EXPRESSION的取法为:
.Any character
[] Any character contained within the brackets
[^] Any character not contained within the brackets
\w A word character [a-z_A-Z0-9]
\W Not a word character [^a-z_A-Z0-9]
\d A digit [0-9]
\D Not a digit [^0-9]
\s Whitespace [ \t\r\n\f\v]
\S Not whitespace [^ \t\r\n\f\v]
那么你的问题就可以使用下面的代码了
>>a='5000.xls'
a =
5000.xls
>> s=a(regexp(a,'\d'))
s =
5000
这时的s是字符型的,如果你需要数字的话就是用str2num转化一下
祝你学习愉快!
用matlab 提取字符串中的数字.
c语言问题,如何将字符串中的数字提取
matlab 画图 横坐标为字符串 我想画一个横坐标是字符串,纵坐标是数字的折线图,请问怎么画?
matlab怎样提取提取一个矩阵中的某些元素?
如何使用公式提取文字中的数字?
按条件提取矩阵中的变量为新矩阵 matlab
matlab 如何提取系数
matlab 数据提取
MATLAB行向量提取
如何一次性提取出word文档中括号中的数字?
有什么函数可以只提取单元格中的所有数字 如单元格中内容为liu123456789 用函数 提取出123456789
跪求用MATLAB编写的关于小波变换数字图像数字边缘提取的程序