4 % Toolbox for nonlinear filtering.
\r
5 % Copyright (C) 2005 Jakob Rosén <jakob.rosen@gmail.com>
\r
7 % This program is free software; you can redistribute it and/or
\r
8 % modify it under the terms of the GNU General Public License
\r
9 % as published by the Free Software Foundation; either version 2
\r
10 % of the License, or (at your option) any later version.
\r
12 % This program is distributed in the hope that it will be useful,
\r
13 % but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 % GNU General Public License for more details.
\r
17 % You should have received a copy of the GNU General Public License
\r
18 % along with this program; if not, write to the Free Software
\r
19 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
23 filter_types=pfgui_config('filter_types');
\r
25 %% Generate the menu
\r
26 filter_number=length(filter_types);
\r
27 filter_objects=cell(1,filter_number);
\r
28 filter_descriptions=cell(1,filter_number);
\r
29 for i=1:filter_number
\r
30 filter_objects{i}=eval(filter_types{i});
\r
31 filter_descriptions{i}=get(filter_objects{i},'description');
\r
33 filter_menu=cell2str(filter_descriptions);
\r
35 disp('Generating models');
\r
36 [model_objects, model_names]=pfgui_example_models;
\r
37 disp('Models generated...');
\r
39 animate_states=[1 2];
\r
44 simulation_steps=10;
\r
46 %% Generate the menu
\r
47 %model_number=length(model_objects);
\r
48 %model_descriptions=cell(model_number+1,1);
\r
49 %model_descriptions{1}='Select a model';
\r
50 %for i=1:model_number
\r
51 %% model_descriptions{i}=[model_names{i},' [',class(model_objects{i}),'] ',num2str(length(model_objects{i}.x0)),' states'];
\r
52 % model_descriptions{i+1}=['[',class(model_objects{i}),'] ',model_names{i},' (',num2str(length(model_objects{i}.x0)),' states)'];
\r
54 %model_menu=cell2str(model_descriptions);
\r
58 % Create the main window
\r
59 hf=figure('Name','Main','Units','Normalized');
\r
60 %hf=figure('Name','Main','NumberTitle','off','Units','Centimeters','Position',[1 3 15 10],'Units','Normalized','PaperUnits','Centimeters','PaperPosition',[0.25 3 18 12]);
\r
63 %uicontrol(hf,'Style','Frame','Units','normalized','Position',[-0.1 -0.1 1.2 1.2]);
\r
66 % Frame + Model text
\r
67 %simulator_tooltip='Before we can do any filtering, we need data to filter. This is usually generated by a simulator, which generates a realization of data according to a certain model. This data is then sent to the filter, in step 2.';
\r
68 simulator_tooltip='Before we can do any filtering, we need data to filter. This data is generated by a simulator.';
\r
69 uicontrol(hf,'Style','Frame','Units','normalized','Position',[0.02 p+0.79 0.96 0.24],'TooltipString',simulator_tooltip);
\r
70 uicontrol(hf,'Style','Text','String','Step 1 - Configure the input','Units','normalized','Position',[0.05 0.06+p+0.95 0.44 0.04],'TooltipString',simulator_tooltip,'FontName','FixedWidth');
\r
73 uicontrol(hf,'Style','Text','String','Mode:','Units','normalized','Position',[0.05 p+0.95 0.26 0.04],'TooltipString',simulator_tooltip,'HorizontalAlign','Left','FontName',myfont);
\r
74 uicontrol(hf,'Style','RadioButton','String','Simulator','Value',1,'Units','Normalized','Position',[0.35 p+0.95 0.2 0.04],'Tag','sim_radio_1','Callback',['pfgui_action(''sim_radio_1'',',num2str(hf),')'],'FontName',myfont);
\r
75 uicontrol(hf,'Style','RadioButton','String','Data from workspace','Value',0,'Units','Normalized','Position',[0.6 p+0.95 0.35 0.04],'Tag','sim_radio_2','Callback',['pfgui_action(''sim_radio_2'',',num2str(hf),')'],'FontName',myfont);
\r
77 % Simulator model selector (visible by default)
\r
78 simulator_steps_tooltip='Defines the amount of discrete steps (samples) that will be simulated each run.';
\r
79 simulator_model_tooltip='The model that will be used for simulating data.';
\r
80 uicontrol(hf,'Style','PopUp','String',model_menu,'Value',1,'Units','normalized','Position',[0.05 p+0.88 0.9 0.05],'Callback',['pfgui_action(''filt_model'',',num2str(hf),')'],'Tag','sim_model','TooltipString',simulator_model_tooltip,'Visible','on','FontName',myfont);
\r
81 uicontrol(hf,'Style','Text','String','Simulation steps:','Units','normalized','Position',[0.05 p+0.81 0.26 0.05],'HorizontalAlign','Left','TooltipString',simulator_steps_tooltip,'Tag','sim_steps_text','Visible','on','FontName',myfont);
\r
82 uicontrol(hf,'Style','Edit','String',num2str(simulation_steps),'Units','normalized','Position',[0.35 p+0.81 0.15 0.05],'Callback',['pfgui_action(''simulation_steps'',',num2str(hf),')'],'Tag','sim_steps','TooltipString',simulator_steps_tooltip,'Visible','on','FontName',myfont);
\r
84 % Simulator data selector (invisible by default)
\r
85 uicontrol(hf,'Style','Text','String','Name of y(t) matrix to be processed:','Units','normalized','Position',[0.05 p+0.88 0.58 0.04],'HorizontalAlign','Left','Tag','sim_y_text','Visible','off','FontName',myfont);
\r
86 uicontrol(hf,'Style','Edit','String','','Units','normalized','Position',[0.6 p+0.88 0.15 0.05],'Callback',['pfgui_action(''y_import'', ', num2str(hf), ')'],'Tag','sim_y_edit','Visible','off','FontName',myfont);
\r
87 uicontrol(hf,'Style','Text','String','[No data]','Units','normalized','Position',[0.78 p+0.88 0.17 0.05],'Tag','sim_y_size','HorizontalAlign','Left','Visible','off','FontName',myfont);
\r
89 uicontrol(hf,'Style','Text','String','Name of true x(t) matrix [optional]:','Units','normalized','Position',[0.05 p+0.81 0.58 0.04],'HorizontalAlign','Left','Tag','sim_x_text','Visible','off','FontName',myfont);
\r
90 uicontrol(hf,'Style','Edit','String','','Units','normalized','Position',[0.6 p+0.81 0.15 0.05],'Callback',['pfgui_action(''x_import'', ', num2str(hf), ')'],'Tag','sim_x_edit','Visible','off','FontName',myfont);
\r
91 uicontrol(hf,'Style','Text','String','[No data]','Units','normalized','Position',[0.78 p+0.81 0.17 0.05],'Tag','sim_x_size','HorizontalAlign','Left','Visible','off','FontName',myfont);
\r
95 % Frame + Filter text
\r
96 filter_tooltip='The data from the simulator is sent to the filter to be processed.';
\r
97 uicontrol(hf,'Style','Frame','Units','normalized','Position',[0.02 p+0.77 0.96 0.26],'TooltipString',filter_tooltip);
\r
98 uicontrol(hf,'Style','Text','String','Step 2 - Filter data','Units','normalized','Position',[0.05 p+1.00 0.3 0.04],'TooltipString',filter_tooltip,'FontName','FixedWidth');
\r
100 % Filter model selector
\r
101 filter_model_tooltip='The model that will be used for filtering the data from step 1.';
\r
102 filter_type_tooltip='The desired filter type.';
\r
103 filter_edit_tooltip='Configure the selected filter.';
\r
104 uicontrol(hf,'Style','PopUp','String',model_menu,'Value',1,'Units','normalized','Position',[0.05 0.20+p+0.74 0.9 0.05],'Callback',['pfgui_action(''filt_model'',',num2str(hf),')'],'Tag','filt_model','TooltipString',filter_model_tooltip,'FontName',myfont);
\r
105 uicontrol(hf,'Style','PopUp','String',filter_menu,'Value',1,'Units','normalized','Position',[0.05 0.20+p+0.67 0.5 0.05],'Callback',['pfgui_action(''filt_type_select'',',num2str(hf),')'],'Tag','filt_type_select','TooltipString',filter_type_tooltip,'FontName',myfont);
\r
106 uicontrol(hf,'Style','Pushbutton','String','Edit filter properties','Units','normalized','Position',[0.57 0.20+p+0.67 0.38 0.05],'Callback',['pfgui_action(''filt_edit_button'',',num2str(hf),')'],'Tag','filt_edit_button','TooltipString',filter_edit_tooltip,'FontName',myfont);
\r
108 uicontrol(hf,'Style','Text','String','Number of runs:','Units','normalized','Position',[0.05 0.20+p+0.60 0.26 0.05],'HorizontalAlign','Left','Tag','filt_runs_text','FontName',myfont);
\r
109 uicontrol(hf,'Style','Edit','String',num2str(runs),'Units','normalized','Position',[0.28 0.20+p+0.60 0.1 0.05],'Callback',['pfgui_action(''edit_runs'',',num2str(hf),')'],'Tag','filt_runs_edit','FontName',myfont);
\r
110 uicontrol(hf,'Style','Checkbox','String','xhat','Units','normalized','Position',[0.57 0.20+p+0.60 0.12 0.05],'Value',1,'HorizontalAlign','Left','Tag','xhat_check','FontName',myfont);
\r
111 uicontrol(hf,'Style','Checkbox','String','xpred','Units','normalized','Position',[0.68 0.20+p+0.60 0.12 0.05],'Value',0,'HorizontalAlign','Left','Tag','xpred_check','FontName',myfont);
\r
114 uicontrol(hf,'Style','Pushbutton','String','FILTER!','Units','normalized','Position',[0.83 0.20+p+0.60 0.12 0.05],'Callback',['pfgui_action(''filter'',',num2str(hf),')'],'Tag','filt_button','FontName',myfont);
\r
118 % Frame + Operations text
\r
119 op_tooltip='After configuring step 1 and 2, we must select an operation. There are three of them.';
\r
120 uicontrol(hf,'Style','Frame','Units','normalized','Position',[0.02 p+1.02 0.96 0.13],'TooltipString',op_tooltip,'FontName',myfont);
\r
121 uicontrol(hf,'Style','Text','String','Step 3 - Choose an operation','Units','normalized','Position',[0.05 p+1.12 0.42 0.04],'TooltipString',op_tooltip,'FontName','FixedWidth');
\r
125 rmse_button_tooltip='Generates the RMSE for a specified amount of runs.';
\r
126 uicontrol(hf,'Style','Pushbutton','String','RMSE','Value',1,'Units','normalized','Position',[0.05 0.46+p+0.6 0.2 0.05],'Callback',['pfgui_action(''rmse_button'',',num2str(hf),')'],'Tag','rmse_button','TooltipString',rmse_button_tooltip,'FontName',myfont);
\r
129 graph_button_tooltip='Generates a 2d-graph of the simulated data and the filtered result.';
\r
130 uicontrol(hf,'Style','Pushbutton','String','Graph','Value',1,'Units','normalized','Position',[0.3 0.46+p+0.6 0.2 0.05],'Callback',['pfgui_action(''graph_button'',',num2str(hf),')'],'Tag','graph_button','TooltipString',graph_button_tooltip,'FontName',myfont);
\r
133 export_button_tooltip='Exports your favourite data';
\r
134 uicontrol(hf,'Style','Pushbutton','String','Export','Value',1,'Units','normalized','Position',[0.55 0.46+p+0.6 0.2 0.05],'Callback',['pfgui_action(''export_button'',',num2str(hf),')'],'Tag','export_button','TooltipString',export_button_tooltip,'FontName',myfont);
\r
138 % Frame + Model text
\r
139 additional_tooltip='Additional parameters that might be useful in some cases.';
\r
140 uicontrol(hf,'Style','Frame','Units','normalized','Position',[0.02 p+0.32 0.96 0.11],'TooltipString',additional_tooltip);
\r
141 uicontrol(hf,'Style','Text','String','Additional parameters','Units','normalized','Position',[0.05 p+0.40 0.34 0.04],'TooltipString',additional_tooltip,'FontName','FixedWidth');
\r
144 u_tooltip='Import u(t) from the workspace';
\r
145 u_text_tooltip='The dimensions of the actual u(t) data';
\r
146 uicontrol(hf,'Style','Text','String','Workspace matrix:','Units','normalized','Position',[0.05 p+0.34 0.3 0.04],'HorizontalAlign','Left','TooltipString',u_tooltip,'FontName',myfont);
\r
147 uicontrol(hf,'Style','Edit','String','','Units','normalized','Position',[0.32 p+0.34 0.15 0.05],'Callback',['pfgui_action(''u_edit'', ', num2str(hf), ')'],'Tag','u_edit','TooltipString',u_tooltip,'FontName',myfont);
\r
148 uicontrol(hf,'Style','Text','String','[No u(t)]','Units','normalized','Position',[0.5 p+0.34 0.3 0.04],'HorizontalAlign','Left','Tag','u_text','TooltipString',u_text_tooltip,'FontName',myfont);
\r
151 time_tooltip='The time of the first step.';
\r
152 uicontrol(hf,'Style','Text','String','Time (t):','Units','normalized','Position',[0.7 p+0.34 0.15 0.04],'HorizontalAlign','Left','TooltipString',time_tooltip,'FontName',myfont);
\r
153 uicontrol(hf,'Style','Edit','String','0','Units','normalized','Position',[0.85 p+0.34 0.1 0.05],'Callback',['pfgui_action(''t_edit'', ', num2str(hf), ')'],'Tag','t_edit','TooltipString',time_tooltip,'FontName',myfont);
\r
156 uicontrol(hf,'Style','Pushbutton','String','Edit models','Value',1,'Units','normalized','Position',[0.02 0.01 0.22 0.05],'Callback',['pfgui_action(''models_button'',',num2str(hf),')'],'Tag','models_button','FontName',myfont);
\r
159 %uicontrol(hf,'Style','Edit','String','','Value',1,'Units','normalized','Position',[0.56 0.00 0.2 0.05],'Tag','diskop_edit','FontName',myfont);
\r
160 %uicontrol(hf,'Style','Pushbutton','String','Load','Value',1,'Units','normalized','Position',[0.78 0.00 0.1 0.05],'Callback',['pfgui_action(''diskop_load'',',num2str(hf),')'],'Tag','diskop_load','FontName',myfont);
\r
161 %uicontrol(hf,'Style','Pushbutton','String','Save','Value',1,'Units','normalized','Position',[0.88 0.00 0.1 0.05],'Callback',['pfgui_action(''diskop_save'',',num2str(hf),')'],'Tag','diskop_save','FontName',myfont);
\r
163 handles=guihandles(hf);
\r
164 handles.model_objects=model_objects;
\r
165 handles.model_names=model_names;
\r
166 handles.filter_objects=filter_objects;
\r
167 handles.filtobj=filter_objects{1};
\r
177 handles.varsize=[0 0 0 0 0]; % x t u w e
\r
178 handles.simulation_steps=simulation_steps;
\r
179 handles.simulator_mode=true;
\r
181 guidata(hf,handles);
\r
182 pfgui_menu_select(hf,1);
\r