Select parts of a string in MATLAB
4 views (last 30 days)
Show older comments
Gautam Marwaha
on 1 Oct 2013
Commented: Azzi Abdelmalek
on 1 Oct 2013
I have a character string that looks something like:
string =
The DOC for the 10 percent ROI = 332.45 dollars/pass
I want to retrieve only the '332.45' bit from it and I'm not sure how to go about it. I have a few possible ways I thought of (but am not sure how to implement):
1. I could select the characters based on where they appear wrt length of the string
2. I could select the characters based on the preceding string sequence.
I would need to repeat this several times since my file has some 1660 such values I need to retrieve.
0 Comments
Accepted Answer
Azzi Abdelmalek
on 1 Oct 2013
Edited: Azzi Abdelmalek
on 1 Oct 2013
EDIT
str =' The DOC for the 10 percent ROI = 332.45 dollars/pass'
out=regexp(str,'\d+\.\d+','match')
2 Comments
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!