import time

3 次查看(过去 30 天)
zheng
zheng 2011-3-22
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

采纳的回答

the cyclist
the cyclist 2011-3-22
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.

更多回答(5 个)

the cyclist
the cyclist 2011-3-22
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 2011-3-22
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 2011-3-22
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 2011-3-22
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 2011-3-22
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