Text files data extract
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, Good morning
I have a very large text file. I here by attached for reference. I want to extraxt nodal displacements for 4961 nodes (1 displ 2 displ) in matrix forma in column wise. I have to extract mutliple times in a loop after every iteration so generalised code will be usefull. Any help would be appreciated. Thank you in advance.
0 Kommentare
Antworten (1)
Mathieu NOE
am 27 Jan. 2021
hello
this seems to work - even though there is maybe a better way to extract the numerical content from the table
I tried with other opts parameters, at the end I could make this to work
% node 1 Coord 2 Coord
% varNames = {'node','1 Coord','2 Coord'} ;
% varTypes = {'int32','double','double'} ;
datalines = [62 5613];
% opts = delimitedTextImportOptions('DataLines',datalines,'VariableNames',varNames ,'VariableTypes',varTypes);
opts = delimitedTextImportOptions('DataLines',datalines,'VariableTypes','char');
data_table = readtable('Onewfp.txt',opts);
[m,n] = size(data_table);
data_C = table2cell(data_table);
% code below could be replaced with correct opts for readtable ?
k = 0;
for ci = 1:m
C = strsplit(data_C{ci});
if ~isnan(str2num(C{1}))
k = k+1;
node_num(k,1) = str2num(C{1});
node1cor(k,1) = str2num(C{2});
node2cor(k,1) = str2num(C{3});
end
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Import and Export finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!