I need to take characters out of a string using isnan and str2double.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Rafael Perales
el 26 de Oct. de 2016
Comentada: Thorsten
el 26 de Oct. de 2016
Basically I need to take out the numeric values out of a string using these functions. I keep trying but some of the characters still come out as numbers.
This is an example
a='281-890-8905';
o=length(a);
for k=1:o
x=isnan(a(k));
if x==0
y=str2double(a(k));
end
end
0 comentarios
Respuesta aceptada
Thorsten
el 26 de Oct. de 2016
cellfun(@(x) sscanf(x, '%f'), regexp(a, '(\d+)', 'match'))
3 comentarios
Ver también
Categorías
Más información sobre Characters and Strings 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!