-
Notifications
You must be signed in to change notification settings - Fork 1
/
Library.m
84 lines (62 loc) · 2.9 KB
/
Library.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Library load %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DB = importdata('materialDB.csv' ,',');
DB_TB_V = importdata('materialDB_TBVogl.csv' ,',');
DB_TB_K = importdata('materialDB_TBKlimeck.csv',',');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
M{1}=Material;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% Here is a patch to be able to load the tables in Matlab AND Octave %%%%%%
% Matlab see the header in multiple cells while Octave see the header in one cell only
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if length(DB.textdata(1,:))==1
DB.textdata{1,1}=[DB.textdata{1,1} ',']; % patch, add a comma "," at the end
idxM=strfind(DB.textdata{1,1},',');
idx=strfind(DB.textdata{1,1},[',' M{1} ',']);
idxM=find(idxM==idx);
M{2} = DB.data(:,idxM);
else
for i=1:length(DB.textdata(1,:))
idx=strcmp(DB.textdata{1,i},M{1});
if idx==1
M{2}=DB.data(:,i-1);
% break % removing the break makes it slower but more compatible between Matlab and Octave
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if length(DB_TB_V.textdata(1,:))==1
DB_TB_V.textdata{1,1}=[DB_TB_V.textdata{1,1} ',']; % patch, add a comma "," at the end
idxM=strfind(DB_TB_V.textdata{1,1},',');
idx=strfind(DB_TB_V.textdata{1,1},[',' M{1} ',']);
idxM=find(idxM==idx);
M{4} = DB_TB_V.data(:,idxM);
else
for i=1:length(DB_TB_V.textdata(1,:))
idx=strcmp(DB_TB_V.textdata{1,i},M{1});
if idx==1
M{4}=DB_TB_V.data(:,i-1);
% break % removing the break makes it slower but more compatible between Matlab and Octave
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if length(DB_TB_K.textdata(1,:))==1
DB_TB_K.textdata{1,1}=[DB_TB_K.textdata{1,1} ',']; % patch, add a comma "," at the end
idxM=strfind(DB_TB_K.textdata{1,1},',');
idx=strfind(DB_TB_K.textdata{1,1},[',' M{1} ',']);
idxM=find(idxM==idx);
M{5} = DB_TB_K.data(:,idxM);
else
for i=1:length(DB_TB_K.textdata(1,:))
idx=strcmp(DB_TB_K.textdata{1,i},M{1});
if idx==1
M{5}=DB_TB_K.data(:,i-1);
% break % removing the break makes it slower but more compatible between Matlab and Octave
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%