Pulling certain data from a text file into Matlab with strsplit
1 view (last 30 days)
Show older comments
Hi, I want a function that reads this text file. It would be better if this could be read with fgetl and strsplit.Thanks!
0 Comments
Answers (1)
Star Strider
on 25 Jan 2022
Try something like this —
% opts = weboptions('ContentType','text');
% M = webread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/873530/miktos1.txt', opts)
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/873530/miktos1.txt', 'ReadVariableNames',0)
for k = 1:size(T1,1)
Var2stsp{k,:} = strsplit(T1{k,2}{:},' ');
end
Var2stsp{1}
Var2stsp{2}
Var2stsp{end-1}
Var2stsp{end}
Experiment to get the desired result.
.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!