function [A] = importAbaqus(filename) % reads xy data from an abaqus.rpt file % % in abaqus viewer you must use the option % "separate table for each XY data" % % looks for different tables and saves each as an % individual matrix within a structure % % to plot the first set of data, simply type: % plot(A(1).data(:,1),A(1).data(:,2)) % to plot the second set of data: % plot(A(2).data(:,1),A(2).data(:,2)) % fid = fopen(filename,'r'); dataset = 0; % repeats infinitely until a "break" is encountered while 1 % read line from file tline = fgetl(fid); % if output is not a character, then its the end of file, so break if ~ischar(tline), break, end % check if we've found a new dataset... this is indicated by a blank % line, cause otherwise we are reading numbers if (strcmp(tline,'')) % because we have found a new dataset, then we are done creating the % previous dataset which is stored in "x", so we save that to our % structure A and clear "x" to prepare for the next dataset. if (dataset > 0) A(dataset).data = x; clear x; end dataset = dataset + 1; index = 1; % read blank lines until we find the dataset name or end of file tline = fgetl(fid); while(strcmp(tline,'')) tline = fgetl(fid); % if output is not a character, then its the end of file, so % break if ~ischar(tline), break, end end % read one blank line before data starts tline = fgetl(fid); % read the first line of data tline = fgetl(fid); end % check for end of file if ~ischar(tline), break, end % this assumes that we've found the start of a dataset and have read % the first line of the data, so we convert it to a number and save it % at the end of the array "x". x(index,:)= str2num(tline); index=index+1; end fclose(fid);