hii.... extract number from string
显示 更早的评论
i have a string which of the form 100*exp(4*x)+156*exp(77*x)+...etc... from this how i get numbers 100,156 etc....?
1 个评论
Jan
2013-7-25
Please post which output you want exactly for the shown input. What about the 4 and the 77?
回答(1 个)
Azzi Abdelmalek
2013-7-25
编辑:Azzi Abdelmalek
2013-7-25
s='100*exp(4*x)+156*exp(77*x)'
out=regexp(s,'\d+','match')
% or if you want to include non integer number
s='100.2*exp(4*x)+156.*exp(77*x)'
out=regexp(s,'[\d]+(\.\d)?','match')
1 个评论
Azzi Abdelmalek
2013-7-25
编辑:Azzi Abdelmalek
2013-7-25
Regarding to Jan's comment, maybe you are just looking for numbers followed by *exp:
s='100*exp(4*x)+156*exp(77*x)'
out=regexp(s,'[\d]+(\.\d)?(?=*exp)','match')
类别
在 帮助中心 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!