Text files data extract

2 Ansichten (letzte 30 Tage)
RAKESH KUMAR TOTA
RAKESH KUMAR TOTA am 26 Jan. 2021
Bearbeitet: RAKESH KUMAR TOTA am 27 Jan. 2021
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.

Antworten (1)

Mathieu NOE
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

Kategorien

Mehr zu Data Import and Export finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by