How can i write from txt files to any array
Show older comments
İ 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
Accepted Answer
More Answers (3)
KSSV
on 2 Aug 2017
0 votes
Read about load , importdata, textscan.
1 Comment
erdem erdemm
on 3 Aug 2017
Jan
on 2 Aug 2017
[fid, msg] = fopen('a001.txt', 'r');
if fid == -1, error('Cannot open file: %s', msg); end
K = fscanf(fid, '%g ', Inf);
fclose(fid);
erdem erdemm
on 3 Aug 2017
0 votes
Categories
Find more on Workspace Variables and MAT Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!