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
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
Azzi Abdelmalek 2013년 7월 25일
편집: Azzi Abdelmalek 2013년 7월 25일

1 개 추천

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
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에 대해 자세히 알아보기

태그

질문:

2013년 7월 25일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by