How to extract number from cell array?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Heidi Mäkitalo
el 13 de Jun. de 2019
Comentada: Heidi Mäkitalo
el 2 de Jul. de 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 comentarios
Respuesta aceptada
madhan ravi
el 13 de Jun. de 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 comentarios
madhan ravi
el 13 de Jun. de 2019
Editada: madhan ravi
el 13 de Jun. de 2019
OR
str2double(regexp(c,'\d+[\.]?\d*','match','once')) % where c is your cell array
Más respuestas (0)
Ver también
Categorías
Más información sobre Cell Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!