import time
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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.
0 个评论
更多回答(5 个)
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.
0 个评论
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.
0 个评论
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Export 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!