Hi all,
I have attached a zipped file containing 3 output files from a finite element analysis software. I would need to process more than 100 hundred of these files. Numerical values are extracted from the output files to calculate "A" and "B" coefficients. I have managed to get this to work for one file at a time, but I want to do this for multiple files in a routine and thus have a complete list of "A" and "B" coefficients. The formatting of the files is identical.
I am new to programming and Matlab. I have been reading about vectorization and for looping in Matlab, but I am getting confused of how to solve this problem. My apologies.
Any assistance would be much appreciated.
%% Clear workspace, clear command window and close all.
clearclcclose all%% Extracting *.out files.
fileinfo = dir('*.out');fnames = sort({fileinfo.name});[F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,F16,F17,F18,F19,...F20,F21,F22,F23,F24,F25,F26,F27,F28,F29,F30,F31,F32,F33,F34,F35,F36] = ...fnames{1:36};%% Use the above created variables in a list to read into the next section.
f = F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,F16,F17,F18,F19,F20,F21,F22,F23,F24,F25,F26,F27,F28,F29,F30,F31,F32,F33,F34,F35,F3;%% Looping through the files to extract values.
a = fileread(f);Lg = 0.75;% find ( H A R M O N I C = \d )
[b,c] = regexp(a,'( H A R M O N I C = \d )','tokens');result = table(); % find the 2nd and the 6th number in the table
for i = 1:length(c) aux = (a(c(i)+586:c(i)+700 )); d = regexp(aux,'([0-9.E-+]*)','tokens'); result = [result;table(repmat(b{i},2,1),[d{2};d{6}])]; end% Converting strings to numbers
result.Var2 = str2double(result.Var2);% Determine "A" cumulative strain functions
A = ((result{2,2}-result{1,2})/Lg)/2.e-6;% Determine "B" cumulative strain functions
B = ((result{4,2}-result{3,2})/Lg)/2.e-6;
Best Answer