📄 kalman_gui.m
字号:
set(handles.R_22, 'String', num2str(data.R(2,2)) );
set(handles.R_23, 'String', num2str(data.R(2,3)) );
set(handles.R_31, 'String', num2str(data.R(3,1)) );
set(handles.R_32, 'String', num2str(data.R(3,2)) );
set(handles.R_33, 'String', num2str(data.R(3,3)) );
set(handles.Q11, 'String', num2str(data.Q(1,1)) );
set(handles.Q12, 'String', num2str(data.Q(1,2)) );
set(handles.Q13, 'String', num2str(data.Q(1,3)) );
set(handles.Q14, 'String', num2str(data.Q(1,4)) );
set(handles.Q15, 'String', num2str(data.Q(1,5)) );
set(handles.Q16, 'String', num2str(data.Q(1,6)) );
set(handles.Q21, 'String', num2str(data.Q(2,1)) );
set(handles.Q22, 'String', num2str(data.Q(2,2)) );
set(handles.Q23, 'String', num2str(data.Q(2,3)) );
set(handles.Q24, 'String', num2str(data.Q(2,4)) );
set(handles.Q25, 'String', num2str(data.Q(2,5)) );
set(handles.Q26, 'String', num2str(data.Q(2,6)) );
set(handles.Q31, 'String', num2str(data.Q(3,1)) );
set(handles.Q32, 'String', num2str(data.Q(3,2)) );
set(handles.Q33, 'String', num2str(data.Q(3,3)) );
set(handles.Q34, 'String', num2str(data.Q(3,4)) );
set(handles.Q35, 'String', num2str(data.Q(3,5)) );
set(handles.Q36, 'String', num2str(data.Q(3,6)) );
set(handles.Q41, 'String', num2str(data.Q(4,1)) );
set(handles.Q42, 'String', num2str(data.Q(4,2)) );
set(handles.Q43, 'String', num2str(data.Q(4,3)) );
set(handles.Q44, 'String', num2str(data.Q(4,4)) );
set(handles.Q45, 'String', num2str(data.Q(4,5)) );
set(handles.Q46, 'String', num2str(data.Q(4,6)) );
set(handles.Q51, 'String', num2str(data.Q(5,1)) );
set(handles.Q52, 'String', num2str(data.Q(5,2)) );
set(handles.Q53, 'String', num2str(data.Q(5,3)) );
set(handles.Q54, 'String', num2str(data.Q(5,4)) );
set(handles.Q55, 'String', num2str(data.Q(5,5)) );
set(handles.Q56, 'String', num2str(data.Q(5,6)) );
set(handles.Q61, 'String', num2str(data.Q(6,1)) );
set(handles.Q62, 'String', num2str(data.Q(6,2)) );
set(handles.Q63, 'String', num2str(data.Q(6,3)) );
set(handles.Q64, 'String', num2str(data.Q(6,4)) );
set(handles.Q65, 'String', num2str(data.Q(6,5)) );
set(handles.Q66, 'String', num2str(data.Q(6,6)) );
% --- Executes on button press in ResetAirplaneButton.
function ResetAirplaneButton_Callback(hObject, eventdata, handles)
% hObject handle to ResetAirplaneButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
data.start_loc = [100000 ;0 ;7000] ; % starting location
data.velocity = -400 ; % velocity in x direction
data.yamp = 1000 ; % amplitude of y maneuvering
data.yperiod = 150 ; % period of y maneuvering
data.zamp = 0 ; % amplitude of z maneuvering
data.zperiod = 0 ; % period of z maneuvering
data.samplingtime = 200 ; % length of time sampled
data.deltat = .04 ; % time between samples
data.sigmaaz = 0.001 ; % standard deviation of azimuth error in radians
data.sigmael = 0.0001 ; % standard deviation of elevation error in radians
data.sigmarange = 12.5 ; % standard deviation of range error in meters
% Kalman filtering information
data.x0 = [0; 0; 0 ; 0 ; 0; 0 ]; % initial state estimate
data.P0 = [100000 0 0 0 0 0 ; % initial covariance estimate
0 10000 0 0 0 0 ;
0 0 1000000 0 0 0 ;
0 0 0 10000 0 0 ;
0 0 0 0 1000000 0 ;
0 0 0 0 0 10000 ];
data.phi = [1 data.deltat 0 0 0 0 ; % state transition matrix
0 1 0 0 0 0 ;
0 0 1 data.deltat 0 0 ;
0 0 0 1 0 0 ;
0 0 0 0 1 data.deltat ;
0 0 0 0 0 1];
data.R = diag([ 100 100 100]) ; % measurement error covariance matrix
data.Q = diag([ 1 0.1 1 0.1 1 0.1]);% state error covariance matrix
set(handles.xstart, 'String', data.start_loc(1));
set(handles.ystart, 'String', data.start_loc(2));
set(handles.zstart, 'String', data.start_loc(3));
set(handles.velocity, 'String', data.velocity);
set(handles.y_amp, 'String', data.yamp);
set(handles.y_period, 'String', data.yperiod);
set(handles.z_amp, 'String', data.zamp);
set(handles.z_period, 'String', data.zperiod);
set(handles.sampletime, 'String', data.samplingtime);
set(handles.deltat, 'String', data.deltat);
set(handles.sigmaaz, 'String', data.sigmaaz);
set(handles.sigmael, 'String', data.sigmael);
set(handles.sigmarange, 'String', data.sigmarange);
set(handles.x0_1, 'String', num2str(data.x0(1)));
set(handles.x0_2, 'String', num2str(data.x0(2)));
set(handles.x0_3, 'String', num2str(data.x0(3)));
set(handles.x0_4, 'String', num2str(data.x0(4)));
set(handles.x0_5, 'String', num2str(data.x0(5)));
set(handles.x0_6, 'String', num2str(data.x0(6)));
set(handles.P11, 'String', num2str(data.P0(1,1)) );
set(handles.P12, 'String', num2str(data.P0(1,2)) );
set(handles.P13, 'String', num2str(data.P0(1,3)) );
set(handles.P14, 'String', num2str(data.P0(1,4)) );
set(handles.P15, 'String', num2str(data.P0(1,5)) );
set(handles.P16, 'String', num2str(data.P0(1,6)) );
set(handles.P21, 'String', num2str(data.P0(2,1)) );
set(handles.P22, 'String', num2str(data.P0(2,2)) );
set(handles.P23, 'String', num2str(data.P0(2,3)) );
set(handles.P24, 'String', num2str(data.P0(2,4)) );
set(handles.P25, 'String', num2str(data.P0(2,5)) );
set(handles.P26, 'String', num2str(data.P0(2,6)) );
set(handles.P31, 'String', num2str(data.P0(3,1)) );
set(handles.P32, 'String', num2str(data.P0(3,2)) );
set(handles.P33, 'String', num2str(data.P0(3,3)) );
set(handles.P34, 'String', num2str(data.P0(3,4)) );
set(handles.P35, 'String', num2str(data.P0(3,5)) );
set(handles.P36, 'String', num2str(data.P0(3,6)) );
set(handles.P41, 'String', num2str(data.P0(4,1)) );
set(handles.P42, 'String', num2str(data.P0(4,2)) );
set(handles.P43, 'String', num2str(data.P0(4,3)) );
set(handles.P44, 'String', num2str(data.P0(4,4)) );
set(handles.P45, 'String', num2str(data.P0(4,5)) );
set(handles.P46, 'String', num2str(data.P0(4,6)) );
set(handles.P51, 'String', num2str(data.P0(5,1)) );
set(handles.P52, 'String', num2str(data.P0(5,2)) );
set(handles.P53, 'String', num2str(data.P0(5,3)) );
set(handles.P54, 'String', num2str(data.P0(5,4)) );
set(handles.P55, 'String', num2str(data.P0(5,5)) );
set(handles.P56, 'String', num2str(data.P0(5,6)) );
set(handles.P61, 'String', num2str(data.P0(6,1)) );
set(handles.P62, 'String', num2str(data.P0(6,2)) );
set(handles.P63, 'String', num2str(data.P0(6,3)) );
set(handles.P64, 'String', num2str(data.P0(6,4)) );
set(handles.P65, 'String', num2str(data.P0(6,5)) );
set(handles.P66, 'String', num2str(data.P0(6,6)) );
set(handles.R_11, 'String', num2str(data.R(1,1)) );
set(handles.R_12, 'String', num2str(data.R(1,2)) );
set(handles.R_13, 'String', num2str(data.R(1,3)) );
set(handles.R_21, 'String', num2str(data.R(2,1)) );
set(handles.R_22, 'String', num2str(data.R(2,2)) );
set(handles.R_23, 'String', num2str(data.R(2,3)) );
set(handles.R_31, 'String', num2str(data.R(3,1)) );
set(handles.R_32, 'String', num2str(data.R(3,2)) );
set(handles.R_33, 'String', num2str(data.R(3,3)) );
set(handles.Q11, 'String', num2str(data.Q(1,1)) );
set(handles.Q12, 'String', num2str(data.Q(1,2)) );
set(handles.Q13, 'String', num2str(data.Q(1,3)) );
set(handles.Q14, 'String', num2str(data.Q(1,4)) );
set(handles.Q15, 'String', num2str(data.Q(1,5)) );
set(handles.Q16, 'String', num2str(data.Q(1,6)) );
set(handles.Q21, 'String', num2str(data.Q(2,1)) );
set(handles.Q22, 'String', num2str(data.Q(2,2)) );
set(handles.Q23, 'String', num2str(data.Q(2,3)) );
set(handles.Q24, 'String', num2str(data.Q(2,4)) );
set(handles.Q25, 'String', num2str(data.Q(2,5)) );
set(handles.Q26, 'String', num2str(data.Q(2,6)) );
set(handles.Q31, 'String', num2str(data.Q(3,1)) );
set(handles.Q32, 'String', num2str(data.Q(3,2)) );
set(handles.Q33, 'String', num2str(data.Q(3,3)) );
set(handles.Q34, 'String', num2str(data.Q(3,4)) );
set(handles.Q35, 'String', num2str(data.Q(3,5)) );
set(handles.Q36, 'String', num2str(data.Q(3,6)) );
set(handles.Q41, 'String', num2str(data.Q(4,1)) );
set(handles.Q42, 'String', num2str(data.Q(4,2)) );
set(handles.Q43, 'String', num2str(data.Q(4,3)) );
set(handles.Q44, 'String', num2str(data.Q(4,4)) );
set(handles.Q45, 'String', num2str(data.Q(4,5)) );
set(handles.Q46, 'String', num2str(data.Q(4,6)) );
set(handles.Q51, 'String', num2str(data.Q(5,1)) );
set(handles.Q52, 'String', num2str(data.Q(5,2)) );
set(handles.Q53, 'String', num2str(data.Q(5,3)) );
set(handles.Q54, 'String', num2str(data.Q(5,4)) );
set(handles.Q55, 'String', num2str(data.Q(5,5)) );
set(handles.Q56, 'String', num2str(data.Q(5,6)) );
set(handles.Q61, 'String', num2str(data.Q(6,1)) );
set(handles.Q62, 'String', num2str(data.Q(6,2)) );
set(handles.Q63, 'String', num2str(data.Q(6,3)) );
set(handles.Q64, 'String', num2str(data.Q(6,4)) );
set(handles.Q65, 'String', num2str(data.Q(6,5)) );
set(handles.Q66, 'String', num2str(data.Q(6,6)) );
% --- Executes on button press in ExitButton.
function ExitButton_Callback(hObject, eventdata, handles)
% hObject handle to ExitButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
clear all;
close all;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- Executes during object creation, after setting all properties.
function R_11_CreateFcn(hObject, eventdata, handles)
% hObject handle to R_11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function R_11_Callback(hObject, eventdata, handles)
% hObject handle to R_11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of R_11 as text
% str2double(get(hObject,'String')) returns contents of R_11 as a double
temp = str2double(get(hObject, 'String'));
if isnan(temp)
set(hObject, 'String', 0);
errordlg('Input must be a number','Error');
end
% --- Executes during object creation, after setting all properties.
function R_12_CreateFcn(hObject, eventdata, handles)
% hObject handle to R_12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function R_12_Callback(hObject, eventdata, handles)
% hObject handle to R_12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of R_12 as text
% str2double(get(hObject,'String')) returns contents of R_12 as a double
% --- Executes during object creation, after setting all properties.
function R_13_CreateFcn(hObject, eventdata, handles)
% hObject handle to R_13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function R_13_Callback(hObject, eventdata, handles)
% hObject handle to R_13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of R_13 as text
% str2double(get(hObject,'String')) returns contents of R_13 as a double
% --- Executes during object creation, after setting all properties.function R_21_CreateFcn(hObject, eventdata, handles)% hObject handle to R_21 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction R_21_Callback(hObject, eventdata, handles)% hObject handle to R_21 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of R_21 as text% str2double(get(hObject,'String')) returns contents of R_21 as a double
% --- Executes during object creation, after setting all properties.
function R_22_CreateFcn(hObject, eventdata, handles)
% hObject handle to R_22 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function R_22_Callback(hObject, eventdata, handles)
% hObject handle to R_22 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of R_22 as text
% str2double(get(hObject,'String')) returns contents of R_22 as a double
% --- Executes during object creation, after setting all properties.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -