Info
此问题已关闭。 请重新打开它进行编辑或回答。
How do it store a particularText file into an array ?
1 次查看(过去 30 天)
显示 更早的评论
I have a Text file (attached along with the question).You can see there are lot of lines at the moment (there can be more) .i want to convert this text file to an array so that the array contains the lines row by row .
I know 'textscan' works but what exactly should my input arguments be so that i get the required result .
Thank you in advance
0 个评论
回答(1 个)
Bob Thompson
2019-4-15
I would suggest loading the file and then splitting.
string = readfile('TestLists.txt');
lines = regexp(string,'\n','split');
3 个评论
Bob Thompson
2019-4-16
readfile is a custom created function. If you would prefer not to use a file of the file exchange then feel free to utilize fileread, importfile, or textscan (use '%s' as the format).
Using the split option with regexp will produce a cell array where each element contains one line of the file.
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!