MATLAB Answers

import time

1 view (last 30 days)
zheng
zheng on 22 Mar 2011
matlab doesnt allow me to import data in such format: 3322282802010072914:43:39:859 Is there any way I can import this kind of data in 33222828020100729144339859
Thanks

Accepted Answer

the cyclist
the cyclist on 22 Mar 2011
Really trying to guess what you want, but maybe you could try using the "readtext" function from the file exchange. It reads files with mixed text and numeric reliably. I have found it useful.

More Answers (5)

the cyclist
the cyclist on 22 Mar 2011
How are the data stored, and how are you trying to retrieve them? You need to supply a lot more detail to get a good answer.
You could import the data as a string, and use the "strrep" command to get rid of the colons.

zheng
zheng on 22 Mar 2011
I want to store all these numbers into a single cell. when I used the 'Import Data' these values become to Nan.

Matt Fig
Matt Fig on 22 Mar 2011
You still have not answered all the cyclist's questions. Go back and read hist questions, then write detailed answers to them.

Matt Tearle
Matt Tearle on 22 Mar 2011
You can use textscan to read arbitrarily formatted data from a text file. If you want to keep the values between the colons separate you could do something like:
data = textscan(fid,'%s:%f:%f:%f')
This will give you a 1-by-4 cell array, where each cell contains an array corresponding to the columns in the file; in this case the first "column" is 3322282802010072914, the second is 43, the third is 39, and the fourth is 859.
Alternatively, as the cyclist suggests, import as a single string, then strip out non-numeric characters. Again, using textscan you'll get a cell array of strings:
x = {'3322282802010072914:43:39:859';'8283812426456345234:12:45:222'}
regexprep(x,'\D','')
Note: no matter which way you go, you won't be able to represent this numerically -- 3322282802010072914 has too many digits to store as a double. That's why in both examples I've used a string.

zheng
zheng on 22 Mar 2011
thank you so much for all of you

Community Treasure Hunt

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

Start Hunting!

Translated by