How to import coordinates from a txt/csv file
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
R2
el 18 de Abr. de 2014
Comentada: R2
el 20 de Abr. de 2014
Hi everyone,
I am very new to MATLAb so this is probably a very basic question. I am trying to write a script to analyse some results I have, I can output my results as either txt or csv files whichever works best. My issue is the file outputs the coordinates in the form (0,0,0) so I am not sure what the best way to import this would be if I wanted to create a 3D scatter plot, as the brackets seem to be causing problems.
Thanks for any help you can offer!
0 comentarios
Respuesta aceptada
per isakson
el 18 de Abr. de 2014
Editada: per isakson
el 18 de Abr. de 2014
Something like this should read your data. Try
>> cac = cssm( )
cac =
[3x3 double]
>> cac{:}
ans =
1 2 3
4 5 6
7 8 9
where
function cac = cssm( )
fid = fopen( 'cssm.txt' );
cac = textscan(fid, '(%f%f%f)', 'CollectOutput', true ...
, 'Delimiter' , ',' );
fclose( fid );
end
and where cssm.txt contains (I'm guessing)
(1,2,3)
(4,5,6)
(7,8,9)
4 comentarios
Image Analyst
el 18 de Abr. de 2014
R2, where did you attach your data file? It's not really fair or helpful to make people who are trying to help you work "blind" by not providing them with your data file. http://www.mathworks.com/matlabcentral/answers/728-how-do-i-write-a-good-question-for-matlab-answers
Más respuestas (1)
Azzi Abdelmalek
el 18 de Abr. de 2014
Editada: Azzi Abdelmalek
el 18 de Abr. de 2014
A=dlmread('Yourfile.txt')
Or
A=xlsread('Yourfile.csv')
Ver también
Categorías
Más información sobre Text Data Preparation 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!