To read a text file using matlab
1 次查看(过去 30 天)
显示 更早的评论
hi, this is a simple question
v='C:\Users\punith\Desktop\1.txt';% path
how to read text file using v
0 个评论
采纳的回答
Honglei Chen
2012-3-6
Use fopen to open the file and then use fscanf or fgetl to read in the content. You can also use fread. For example, the following code reads the first line of the text.
fid = fopen(v,'r');
tline = fgetl(fid);
fclose(fid)
Just to remember close the file using fclose afterwards.
doc fopen
doc fclose
doc fread
doc fscanf
doc fgetl
更多回答(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!