Info
此问题已关闭。 请重新打开它进行编辑或回答。
Importing a text with header
1 次查看(过去 30 天)
显示 更早的评论
Hi All I have a text file that i want to import to Matlab. This file is as shown: * Item one % 1 text text tex * Item two 1 2 2 3 4 5 3 2 * Item three % 2 text text text * Item four 12 12 45 7 8 6
how can i import the two vectors? Thanks
0 个评论
回答(2 个)
Richard
2012-3-28
Its hard to say with the example you provided but I think you should be looking at using textscan
2 个评论
Ken Atwell
2012-4-3
Sermed, textscan is likely the right chose. Read the doc page lestyn indicated, especially the CommentStyle option -- you should be able to ignore lines that begin with a '%'.
Richard
2012-3-29
by saying lines, do you mean row or column vectors? Either way, try to use dlmread first:
M = dlmread(filename)
so your filename will be the path where the text file is located e.g.
C:\My Documents\textFile.txt
where textFile is the specific name of your text file. If this doesn't work let me know and we can try and think of another method.
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!