Hi, I am trying to import data files that have multiple delimiters. For example, the first data line is: 1.3001 3.5602 Importing the data file and using tab delimited give me column 1 of 1.3001 and column 2 of 3.5602. This is fine, as the second column is actually the decimal number of 3.5602. However, column 1 needs split up into a column that would include 1 and a column that would include 3001. Simply trying to use both tab and '.' delimiting will give me four columns, of 1, 3001, 3, and 5602; I need 3 columns of 1, 3001, and 3.5602. Any suggestions?

댓글 수: 2

sixwwwwww
sixwwwwww 2013년 10월 11일
First import all data using tab delimiter then you can use '.' delimiter on first column only. It will give you desired 3 columns
Mason
Mason 2013년 10월 11일
I have been importing the data using the tab delimiter, but I am not familiar with how to use a delimiter like '.' on a particular column. I'm not that familiar with Matlab :(

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

 채택된 답변

sixwwwwww
sixwwwwww 2013년 10월 11일

0 개 추천

Here is an example of using dot delimiter:
a = 599.666;
b = num2str(a);
c = strsplit(b, '.');
first_element = str2num(c{1})
second_element = str2num(c{2})

댓글 수: 2

Mason
Mason 2013년 10월 11일
Thanks for your help on this. It makes intuitive sense. However, the program keeps spitting back at me "undefined function 'strsplit' for input arguments of type 'char'" and when I type "help strsplit" it says it's not found?
sixwwwwww
sixwwwwww 2013년 10월 11일
편집: sixwwwwww 2013년 10월 11일
Which version of MATLAB are you using? You can also find help for it online: http://www.mathworks.com/help/matlab/ref/strsplit.html

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Cell Arrays에 대해 자세히 알아보기

태그

질문:

2013년 10월 11일

댓글:

2013년 10월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by