-
Notifications
You must be signed in to change notification settings - Fork 1
/
read_mat_props_interp.m
executable file
·66 lines (58 loc) · 2.44 KB
/
read_mat_props_interp.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function [fea_props]= read_mat_props_interp
[FileName,PathName] = uigetfile({'*.prop'},'Select File');
if FileName == 0
return;
end
if ~strcmpi(FileName(end-4:end), '.prop')
errordlg('This file is not a material data file. File name must end with: ''*.prop''',...
'File Error');
return;
end
FullFileName = strcat(PathName,FileName);
%[Text] = textread(FullFileName, '%[^\n]');
fid = fopen(FullFileName, 'rt');
ts = textscan(fid, '%[^\r\n]');
Text = ts{1};
% base_index = strmatch('*material', Text);
% end_index = strmatch('*end_material', Text, 'exact');
base_index = find_string_index('*material', Text);
end_index = find_string_index('*end_material', Text);
fea_props.base_index = base_index;
% se_index = strmatch('*stress', Text);
se_index = find_string_index('*stress', Text);
fea_props.se_index = se_index;
%read base metal properties
if ~isempty(base_index)
% E_index = strmatch('*E', Text);
E_index = find_string_index('*E', Text);
fea_props.base_E = sscanf(Text{E_index},'%*s %f');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%added these lines 3/8/12 to assist in interpolation routine
fea_props.FileName = FileName;
fea_props.FullFileName = FullFileName;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fea_props.length_base_table = end_index-se_index-1;
if ~isempty(se_index)
for i = 1:fea_props.length_base_table
% fea_props.base_se(i,1) = sscanf(Text{base_index+2+i},'%f , %*f');
% fea_props.base_se(i,2) = sscanf(Text{base_index+2+i},'%*f , %f');
%use textscan to allow reading of tab, space, or comma delimited
%data
fea_props.base_se_cell(i,1) = textscan(Text{se_index+i},'%f %*f', 'delimiter', ',');
fea_props.base_se_cell(i,2) = textscan(Text{se_index+i},'%*f %f', 'delimiter', ',');
%pull out of cell array
fea_props.base_se(i,1) = fea_props.base_se_cell{i,1};
fea_props.base_se(i,2) = fea_props.base_se_cell{i,2};
end
else
% Sys_index = strmatch('*Sys', Text);
% n_index = strmatch('*n', Text);
Sys_index = find_string_index('*Sys', Text);
n_index = find_string_index('*n', Text);
fea_props.Sys_NotTable = sscanf(Text{Sys_index},'%*s %f');
fea_props.n = sscanf(Text{n_index},'%*s %f');
fea_props.base_se(1,1) = 0;
fea_props.base_se(1,2) = 0;
end
end
end