MATLAB: Extract nodes and elements from abaqus input file to matlab

abaqus input fileMATLAB

Hello,
I have an abaqus input file with the following structure:
Now I want to extract the nodes and elements to matlab in order to do computations there. I have two problems:
  • The nodes of each elements are written in 2 lines. How can I change this to one line without joining each line individually?
  • Whats in general the easiest and fastest way to read this out?
Thanks

Best Answer

clc; clear all ;
fname = 'example.txt' ;
fid = fopen(fname,'rt') ;
S = textscan(fid,'%s','Delimiter','\n');
S = S{1} ;
%%Get the line number of mises
idxS = strfind(S, 'Node');
idx1 = find(not(cellfun('isempty', idxS)));
idxS = strfind(S, 'Element');
idx2 = find(not(cellfun('isempty', idxS)));
idxS = strfind(S, 'End');
idx3 = find(not(cellfun('isempty', idxS)));
% pick nodes
nodes = S(idx1+1:idx2-1) ;
nodes = cell2mat(cellfun(@str2num,nodes,'UniformOutput',false))
% pick elements
elements = S(idx2+1:idx3(1)-1) ;
count = 0 ;
ele = cell(length(elements)/2,1) ;
for i = 1:2:length(elements)
count = count+1 ;
ele{count,1} = [elements{i} elements{i+1}];
end
ele = cell2mat(cellfun(@str2num,ele,'UniformOutput',false))