Pulling certain data from a text file into Matlab with strsplit
Mostrar comentarios más antiguos
Hi, I want a function that reads this text file. It would be better if this could be read with fgetl and strsplit.Thanks!
Respuestas (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.
.
Categorías
Más información sobre Cell Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!