How to extract number from cell array?
5 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
madhan ravi
2019 年 6 月 13 日
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 件のコメント
madhan ravi
2019 年 6 月 13 日
編集済み: madhan ravi
2019 年 6 月 13 日
OR
str2double(regexp(c,'\d+[\.]?\d*','match','once')) % where c is your cell array
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Cell Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!