How to extract number from cell array?
5 views (last 30 days)
Show older comments
Heidi Mäkitalo
on 13 Jun 2019
Commented: Heidi Mäkitalo
on 2 Jul 2019
I have a cell array that contains only the following text: 'Interval: 0.02 sec'. How can I extract the number 0.02 from the cell, to be used in calculations?
0 Comments
Accepted Answer
madhan ravi
on 13 Jun 2019
cellfun(@(x) sscanf(x,'Interval: %f'),c,'un',0) % assuming follows the same pattern , turn 0 to 1 if it’s a scalar output.
2 Comments
madhan ravi
on 13 Jun 2019
Edited: madhan ravi
on 13 Jun 2019
OR
str2double(regexp(c,'\d+[\.]?\d*','match','once')) % where c is your cell array
More Answers (0)
See Also
Categories
Find more on Cell Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!