rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
load_opt_data.m
Go to the documentation of this file.
1 function opt_data = load_opt_data(filestr, model)
2 %model = load_opt_data(filestr, model)
3 %
4 %Function loads optimization data from file named filestr.
5 %
6 %04.03.2010 Markus Dihlmann
7 
8 
9 Pfad=[getenv('RBMATLABTEMP'), '/',filestr];
10 
11 fid = fopen(Pfad,'r');
12 
13 str=fgetl(fid);
14 while(~strcmp(str(1:8),'Printing'))
15  str=fgetl(fid);
16  while(length(str)<8)
17  str=fgetl(fid);
18  end
19 end
20 
21 str=fgetl(fid);
22 str=fgetl(fid);
23 index=1;
24 opt_data=[];
25 while(str~=-1)
26  k = strfind(str, sprintf('\t'));
27  opt_data.output(index)=str2double(str(1:k(1)));
28  for i=1:length(k)-1
29  opt_data.parameter_sets(index,i)=str2double(str(k(i):k(i+1)));
30  end
31 
32  index=index+1;
33  str=fgetl(fid);
34 end
35 
36 opt_data.max_output = max(opt_data.output);
37 
38 %where to reach this maximum value:
39 ind=1;
40 Pmax=[];
41 ind=search_pos(opt_data.max_output, opt_data.output,ind);
42 while(ind>0)
43  Pmax=[Pmax;opt_data.parameter_sets(ind,:)];
44  ind=search_pos(opt_data.max_output, opt_data.output,ind+1);
45 end
46 
47 opt_data.max_output_paramsets=Pmax;
48 
49 
50 fclose(fid);
51 
52 
53 end
54 
55 
56 
57 function ind=search_pos(value,vec,start)
58  found=0;
59  ind=start;
60  while ((~found)&&(ind<=length(vec)))
61  if(vec(ind)==value)
62  found=1;
63  else
64  ind = ind+1;
65  end
66  end
67 
68  if(ind>length(vec))
69  ind=-1;
70  end
71 
72 end
function opt_data = load_opt_data(filestr, model)
model = load_opt_data(filestr, model)
Definition: load_opt_data.m:17