How can i write from txt files to any array
1 次查看(过去 30 天)
显示 更早的评论
İ have any a txt files.
a001.txt
152 583 -129 -523 125 etc..
i want to use them in an array. i want to use each one like a quantitive number. as a result i want that k array is a.txt
k= 152 583 -129 -523 125
thanks
0 个评论
采纳的回答
更多回答(3 个)
Jan
2017-8-2
[fid, msg] = fopen('a001.txt', 'r');
if fid == -1, error('Cannot open file: %s', msg); end
K = fscanf(fid, '%g ', Inf);
fclose(fid);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Workspace Variables and MAT Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!