How to put text into an array
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
mt
el 24 de Oct. de 2014
Comentada: Image Analyst
el 27 de Oct. de 2014
Hi all,
I have a big text right now and I wish to put every line as an array... could someone help?
201403 0.000 8.333 0.00 0.00
So this is one of the lines of my text, and I wish to sort it as an array like
2014 03 0.000 8.333 0.00 0.00
Can anybody help please?
Thanks!
1 comentario
per isakson
el 24 de Oct. de 2014
Editada: per isakson
el 24 de Oct. de 2014
I don't understand your question. What do the other lines look like and what should happen to them?
Respuesta aceptada
per isakson
el 24 de Oct. de 2014
Editada: per isakson
el 24 de Oct. de 2014
Hint:
>> str = '201403 0.000 8.333 0.00 0.00';
>> cac = textscan( str, '%4f%2f%f%f%f%f', 'CollectOutput', true )
cac =
[1x6 double]
>> cac{:}
ans =
1.0e+03 *
2.0140 0.0030 0 0.0083 0 0
4 comentarios
Image Analyst
el 27 de Oct. de 2014
I don't understand the second sentence. What do you mean by "on these formats"? Just call fopen(), have your loop with textscan() inside, then call fclose(). What's the problem you are having? Are we supposed to know what your code is? If so, you'll have to post it.
Más respuestas (0)
Ver también
Categorías
Más información sobre Text Files 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!