hii.... extract number from string
Mostrar comentarios más antiguos
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 comentario
Jan
el 25 de Jul. de 2013
Please post which output you want exactly for the shown input. What about the 4 and the 77?
Respuestas (1)
Azzi Abdelmalek
el 25 de Jul. de 2013
Editada: Azzi Abdelmalek
el 25 de Jul. de 2013
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 comentario
Azzi Abdelmalek
el 25 de Jul. de 2013
Editada: Azzi Abdelmalek
el 25 de Jul. de 2013
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')
Categorías
Más información sobre Cell Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!