import time

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

 Risposta accettata

the cyclist
the cyclist il 22 Mar 2011

0 voti

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.

Più risposte (5)

the cyclist
the cyclist il 22 Mar 2011

0 voti

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 il 22 Mar 2011

0 voti

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 il 22 Mar 2011

0 voti

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 il 22 Mar 2011

0 voti

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 il 22 Mar 2011

0 voti

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