Pulling certain data from a text file into Matlab with strsplit
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!
Answers (1)
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.
.
Categories
Find more on Cell Arrays 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!