필터 지우기
필터 지우기

How to import coordinates from a txt/csv file

조회 수: 14 (최근 30일)
R2
R2 2014년 4월 18일
댓글: R2 2014년 4월 20일
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!

채택된 답변

per isakson
per isakson 2014년 4월 18일
편집: per isakson 2014년 4월 18일
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
Image Analyst
Image Analyst 2014년 4월 18일
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
R2
R2 2014년 4월 20일
Sorry about that I made a silly mistake the answer works perfectly, thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 18일
편집: Azzi Abdelmalek 2014년 4월 18일
A=dlmread('Yourfile.txt')
Or
A=xlsread('Yourfile.csv')
  댓글 수: 1
R2
R2 2014년 4월 18일
I've tried both dlmread and csvread and they both don't work I'm guessing because of the format of the output being (0,0,0)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by