-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathparseSF.m
68 lines (66 loc) · 2.25 KB
/
parseSF.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
function [Surfaces ] = parseSF( filename )
% Copyright 2012 Joseph Moster
file = textread(filename, '%s', 'delimiter', '\n','whitespace', '');
% Surfaces;
surfIndex=1;
i=1;
while i<length(file)
str = char(file(i));
header = regexp(str, 'Surface #', 'once');
if(~isempty(header))
clearvars surface
surface.name = strtrim(str(18:length(str)));
i=i+1;
while i<length(file)
str = char(file(i));
header = regexp(str, 'Strip Forces referred to Strip Area, Chord', 'once');
if(~isempty(header))
i=i+2;
str = char(file(i));
j=1;
while(~isempty(str) && i<length(file))
surface.strip{j} = readLine(str);
j=j+1;
i=i+1;
str = char(file(i));
end
break;
end
i=i+1;
end
Surfaces(surfIndex) = surface;
surfIndex = surfIndex+1;
end
i=i+1;
end
function [strip] = readLine(string)
string = [string ' '];
s2 = regexp(string, ' ', 'split');
%j Yle Chord Area c cl ai cl_norm cl
%cd cdv cm_c/4 cm_LE C.P.x/c
[strip.j, sIndex] = readValue(s2,1);
[strip.Yle, sIndex] = readValue(s2,sIndex+1);
[strip.Chord, sIndex] = readValue(s2,sIndex+1);
[strip.Area, sIndex] = readValue(s2,sIndex+1);
[strip.ccl, sIndex] = readValue(s2,sIndex+1);
[strip.ai, sIndex] = readValue(s2,sIndex+1);
[strip.cl_norm, sIndex] = readValue(s2,sIndex+1);
[strip.cl, sIndex] = readValue(s2,sIndex+1);
[strip.cd, sIndex] = readValue(s2,sIndex+1);
[strip.cdv, sIndex] = readValue(s2,sIndex+1);
[strip.cm_c4, sIndex] = readValue(s2,sIndex+1);
[strip.cm_LE, sIndex] = readValue(s2,sIndex+1);
[strip.CPxc, sIndex] = readValue(s2,sIndex+1);
end
function [val,endIndex] = readValue(s2,index)
val = 'NAN';
while index<length(s2)
if(length(char(s2(index)))>=1)
val = str2double(char(s2(index)));
break;
end
index = index+1;
end
endIndex = index;
end
end