How to extract text and value from a .txt file ?
1 次查看(过去 30 天)
显示 更早的评论
Hi,
i have to import an array from a .txt file into Matlab. The problem is I have 2 arrays of similar shape that contain text and numbers (I would like both).
I tried using "uiimport" (which is convenient since I'm making a GUI): It works well with the file1 : I get a "data" matrix (I don't know what it is) and a "textdata" cell array which I can work with.
However here is the problem, with the file2, the "textdata" cell array only contains the first line.
Could you please help me find a solution ?
(I suggest the problem may be related to the last column being empty)
7 个评论
Kian Azami
2017-10-2
@Guillaume thank you for your comment. I didn't know it. For the next times I will answer the questions instead of put a comment.
采纳的回答
aL
2017-9-29
You can use the readtable command.
filedata = readtable('file2.txt','delimiter','\t','readvariablenames',true);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!