Hello,
I just wanted to inform you that it can occur that the ind-vector can have NaN entries. This leads to an error of the script in the second for-loop. To overcome this I modified the file a little bit. The script works correct. I compared all extracted node coordinates and numbers with the input file. Below you see the modified script.
function out = Rec1901(Rec)
%
% ABAQUS node definition output to MATLAB
%
% Syntax
% #Rec# = Fil2str('*.fil');
% #out# = Rec1901(#Rec#)
%
% Description
% Read node definition output from the results (*.fil) file generated
% from the ABAQUS finite element software. The asterisk (*) is replaced
% by the name of the results file. The record key for node definition
% output is 1901. See section < < Results file output format > > in ABAQUS
% Analysis User's manual for more details.
% The following option with parameter has to be specified in the ABAQUS
% input file for the results (*.fil) file to be created:
% ...
% *FILE FORMAT, ASCII
% ...
% NOTE: The results file (*.fil) must be placed in the same directory
% with the MATLAB source files in order to be processed.
%
% Input parameters
% #Rec# (string) is an one-row string containing the ASCII code of the
% ABAQUS results (*.fil) file. It is generated by the function
% Fil2str.m.
%
% Output parameters
% #out# ([#n# x #m#]) is a double array containing the attributes of
% the record key 1901 as follows:
% Column 1 – Node number.
% Column 2 – First coordinate.
% Column 3 – Second coordinate.
% Column 4 – etc.
% where #n# is the number of nodes and #m#-1 is the number of
% coordinates per node. If the results file does not contain the
% desired output, #out# will be an empty array
%
% _________________________________________________________________________
% Abaqus2Matlab - www.abaqus2matlab.com
% Copyright (c) 2016 by George Papazafeiropoulos
%
% If using this toolbox for research or industrial purposes, please cite:
% G. Papazafeiropoulos, M. Muniz-Calvente, E. Martinez-Paneda.
% Abaqus2Matlab: a suitable tool for finite element post-processing (submitted)
%
%
ind = strfind(Rec,'I 41901'); % record key for node definition output (1901)
if isempty(ind)
out=[];
return;
end
nextpos=numel('I 41901')+1;
% Initialize
NodeNum=zeros(numel(ind),1);
% Initialize record length matrix
NW=zeros(numel(ind),1);
for i=1:numel(ind)
% find the record length (NW)
Rec2=Rec(ind(i)-7:ind(i));
indNW=strfind(Rec2,'*'); % record starting position
% ensure that the record exists and that the record type key is at
% location 2
if isempty(indNW) || indNW>3
ind(i)=NaN;
continue;
end
% number of digits of record length
ind1=indNW+2; % 1st digit of 2-digit integer of 1st data item
ind2=indNW+2+1; % 2nd digit of 2-digit integer of 1st data item
a1=str2num(Rec2(ind1:ind2));
% Record length (NW)
ind1=ind1+2; % +2 digits
ind2=ind2+a1; % +2-digit integer
NW(i)=str2num(Rec2(ind1:ind2));
end
NodeCoords=zeros(numel(ind),max(NW)-3);
for i=1:numel(ind)
% Check if ind has an NaN entry or not
if isnan(ind(i))
else
% number of digits of node number
ind1=ind(i)+nextpos; % 1st digit of 2-digit integer of 3rd data item
ind2=ind(i)+nextpos+1; % 2nd digit of 2-digit integer of 3rd data item
a1=str2num(Rec(ind1:ind2));
% Node number
ind1=ind1+2; % +2 digits
ind2=ind2+a1; % +2-digit integer
NodeNum(i)=str2num(Rec(ind1:ind2));
% Node coordinates
for j=1:NW(i)-3
% node coordinate
ind1=ind2+1+1; % +1 character+1
ind2=ind2+1+22; % +1 character +22 floating point digits
NodeCoords(i,j)=str2num(Rec(ind1:ind2));
end
end
end
% Assemply of matrices for output
out=[NodeNum NodeCoords];
% Delete rows with zero entries
out(~any(out'),:) = [];
end
Good morning Joachim!
Thank you very much for the explanation. I see the issue. I would be grateful if you could share the input file that gave the error.
Best,
George