dot and tab delimiting

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 Commenti

sixwwwwww
sixwwwwww il 11 Ott 2013
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 il 11 Ott 2013
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 :(

Accedi per commentare.

 Risposta accettata

sixwwwwww
sixwwwwww il 11 Ott 2013
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 Commenti

Mason
Mason il 11 Ott 2013
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 il 11 Ott 2013
Modificato: sixwwwwww il 11 Ott 2013
Which version of MATLAB are you using? You can also find help for it online: http://www.mathworks.com/help/matlab/ref/strsplit.html

Accedi per commentare.

Più risposte (0)

Categorie

Richiesto:

il 11 Ott 2013

Commentato:

il 11 Ott 2013

Community Treasure Hunt

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

Start Hunting!

Translated by