【圖像處理】打靶仿真系統(tǒng)含Matlab源碼
【圖像處理】打靶仿真系統(tǒng)含Matlab源碼
TT_Matlab
博主簡介:擅長智能優(yōu)化算法、神經(jīng)網(wǎng)絡(luò)預(yù)測、信號處理、元胞自動機、圖像處理、路徑規(guī)劃、無人機等多種領(lǐng)域的Matlab仿真,完整matlab代碼或者程序定制加qq1575304183。
1 簡介
2 部分代碼
function
varargout = target_export(varargin)
% TARGET_EXPORT M-file for target_export.fig
% TARGET_EXPORT, by itself, creates a new TARGET_EXPORT or raises the existing
% singleton*.
%
% H = TARGET_EXPORT returns the handle to a new TARGET_EXPORT or the handle to
% the existing singleton*.
%
% TARGET_EXPORT(
’CALLBACK’
,hObject,eventData,handles,...) calls the local
% function named CALLBACK in TARGET_EXPORT.M with the given input arguments.
%
% TARGET_EXPORT(
’Property’
,
’Value’
,...) creates a new TARGET_EXPORT or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before target_export_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to target_export_OpeningFcn via varargin.
%
% *See GUI Options
on
GUIDE
’s Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help target_export
% Last Modified by GUIDE v2.5 09-Dec-2010 23:29:22
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct(’
gui_Name
’, mfilename, ...
’
gui_Singleton
’, gui_Singleton, ...
’
gui_OpeningFcn
’,
@target_export_OpeningFcn
, ...
’
gui_OutputFcn
’,
@target_export_OutputFcn
, ...
’
gui_LayoutFcn
’,
@target_export_LayoutFcn
, ...
’
gui_Callback
’, []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before target_export is made visible.
function target_export_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to target_export (see VARARGIN)
%畫靶子
draw;
% Choose default command line output for target_export
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes target_export wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = target_export_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in close.
function close_Callback(hObject, eventdata, handles)
% hObject handle to close (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close;
function uh_input_Callback(hObject, eventdata, handles)
% hObject handle to uh_input (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 uh_input as text
% str2double(get(hObject,’
String
’)) returns contents of uh_input as a double
% --- Executes during object creation, after setting all properties.
function uh_input_CreateFcn(hObject, eventdata, handles)
% hObject handle to uh_input (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 && isequal(get(hObject,’
BackgroundColor
’), get(0,’
defaultUicontrolBackgroundColor
’))
set(hObject,’
BackgroundColor
’,’
white
’);
end
function vh_input_Callback(hObject, eventdata, handles)
% hObject handle to vh_input (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 vh_input as text
% str2double(get(hObject,’
String
’)) returns contents of vh_input as a double
% --- Executes during object creation, after setting all properties.
function vh_input_CreateFcn(hObject, eventdata, handles)
% hObject handle to vh_input (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 && isequal(get(hObject,’
BackgroundColor
’), get(0,’
defaultUicontrolBackgroundColor
’))
set(hObject,’
BackgroundColor
’,’
white
’);
end
function vr_input_Callback(hObject, eventdata, handles)
% hObject handle to vr_input (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 vr_input as text
% str2double(get(hObject,’
String
’)) returns contents of vr_input as a double
% --- Executes during object creation, after setting all properties.
function vr_input_CreateFcn(hObject, eventdata, handles)
% hObject handle to vr_input (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 && isequal(get(hObject,’
BackgroundColor
’), get(0,’
defaultUicontrolBackgroundColor
’))
set(hObject,’
BackgroundColor
’,’
white
’);
end
function ur_input_Callback(hObject, eventdata, handles)
% hObject handle to ur_input (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 ur_input as text
% str2double(get(hObject,’
String
’)) returns contents of ur_input as a double
% --- Executes during object creation, after setting all properties.
function ur_input_CreateFcn(hObject, eventdata, handles)
% hObject handle to ur_input (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 && isequal(get(hObject,’
BackgroundColor
’), get(0,’
defaultUicontrolBackgroundColor
’))
set(hObject,’
BackgroundColor
’,’
white
’);
end
function ah_input_Callback(hObject, eventdata, handles)
% hObject handle to ah_input (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 ah_input as text
% str2double(get(hObject,’
String
’)) returns contents of ah_input as a double
% --- Executes during object creation, after setting all properties.
function ah_input_CreateFcn(hObject, eventdata, handles)
% hObject handle to ah_input (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 && isequal(get(hObject,’
BackgroundColor
’), get(0,’
defaultUicontrolBackgroundColor
’))
set(hObject,’
BackgroundColor
’,’
white
’);
end
function ar_input_Callback(hObject, eventdata, handles)
% hObject handle to ar_input (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 ar_input as text
% str2double(get(hObject,’
String
’)) returns contents of ar_input as a double
% --- Executes during object creation, after setting all properties.
function ar_input_CreateFcn(hObject, eventdata, handles)
% hObject handle to ar_input (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 && isequal(get(hObject,’
BackgroundColor
’), get(0,’
defaultUicontrolBackgroundColor
’))
set(hObject,’
BackgroundColor
’,’
white
’);
end
function bh_input_Callback(hObject, eventdata, handles)
% hObject handle to bh_input (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 bh_input as text
% str2double(get(hObject,’
String
’)) returns contents of bh_input as a double
% --- Executes during object creation, after setting all properties.
function bh_input_CreateFcn(hObject, eventdata, handles)
% hObject handle to bh_input (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 && isequal(get(hObject,’
BackgroundColor
’), get(0,’
defaultUicontrolBackgroundColor
’))
set(hObject,’
BackgroundColor
’,’
white
’);
end
function br_input_Callback(hObject, eventdata, handles)
% hObject handle to br_input (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 br_input as text
% str2double(get(hObject,’
String
’)) returns contents of br_input as a double
% --- Executes during object creation, after setting all properties.
function br_input_CreateFcn(hObject, eventdata, handles)
% hObject handle to br_input (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 && isequal(get(hObject,’
BackgroundColor
’), get(0,’
defaultUicontrolBackgroundColor
’))
set(hObject,’
BackgroundColor
’,’
white
’);
end
function distance_input_Callback(hObject, eventdata, handles)
% hObject handle to distance_input (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 distance_input as text
% str2double(get(hObject,’
String
’)) returns contents of distance_input as a double
% --- Executes during object creation, after setting all properties.
function distance_input_CreateFcn(hObject, eventdata, handles)
% hObject handle to distance_input (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 && isequal(get(hObject,’
BackgroundColor
’), get(0,’
defaultUicontrolBackgroundColor
’))
set(hObject,’
BackgroundColor
’,’
white
’);
end
function sum_output_Callback(hObject, eventdata, handles)
% hObject handle to sum_output (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 sum_output as text
% str2double(get(hObject,’
String
’)) returns contents of sum_output as a double
% --- Executes during object creation, after setting all properties.
function sum_output_CreateFcn(hObject, eventdata, handles)
% hObject handle to sum_output (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 && isequal(get(hObject,’
BackgroundColor
’), get(0,’
defaultUicontrolBackgroundColor
’))
set(hObject,’
BackgroundColor
’,’
white
’);
end
function average_output_Callback(hObject, eventdata, handles)
% hObject handle to average_output (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 average_output as text
% str2double(get(hObject,’
String
’)) returns contents of average_output as a double
% --- Executes during object creation, after setting all properties.
function average_output_CreateFcn(hObject, eventdata, handles)
% hObject handle to average_output (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 && isequal(get(hObject,’
BackgroundColor
’), get(0,’
defaultUicontrolBackgroundColor
’))
set(hObject,’
BackgroundColor
’,’
white
’);
end
function n_output_Callback(hObject, eventdata, handles)
% hObject handle to n_output (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 n_output as text
% str2double(get(hObject,’
String
’)) returns contents of n_output as a double
% --- Executes during object creation, after setting all properties.
function n_output_CreateFcn(hObject, eventdata, handles)
% hObject handle to n_output (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 && isequal(get(hObject,’
BackgroundColor
’), get(0,’
defaultUicontrolBackgroundColor
’))
set(hObject,’
BackgroundColor
’,’
white
’);
end
% --- Executes on button press in start.
function start_Callback(hObject, eventdata, handles)
% hObject handle to start (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%畫靶子
draw;
%清除輸出結(jié)果
set(handles.sum_output,’
string
’,’
’);
set(handles.average_output,’
string
’,’
’);
set(handles.n_output,’
string
’,’
’);
set(handles.out1,’
string
’,’
’);
set(handles.out2,’
string
’,’
’);
set(handles.out3,’
string
’,’
’);
set(handles.out4,’
string
’,’
’);
set(handles.out5,’
string
’,’
’);
set(handles.out6,’
string
’,’
’);
set(handles.out7,’
string
’,’
’);
set(handles.out8,’
string
’,’
’);
set(handles.out9,’
string
’,’
’);
set(handles.out10,’
string
’,’
’);
%獲取用戶輸入的武器參數(shù)和射擊距離,沒有輸入則獲取默認(rèn)參數(shù)
uh=str2double(get(handles.uh_input,’
string
’));
ur=str2double(get(handles.ur_input,’
string
’));
vh=str2double(get(handles.vh_input,’
string
’));
vr=str2double(get(handles.vr_input,’
string
’));
ah=str2double(get(handles.ah_input,’
string
’));
ar=str2double(get(handles.ar_input,’
string
’));
bh=str2double(get(handles.bh_input,’
string
’));
br=str2double(get(handles.br_input,’
string
’));
distance=str2double(get(handles.distance_input,’
string
’));
%計算武器瞄準(zhǔn)偏差和射彈散布偏差
Eh=uh*exp(vh*distance);
Er=vr*exp(vh*distance);
Bh=ah*power(distance,bh);
Br=ar*power(distance,br);
%在靶上標(biāo)出位置,并且計算總環(huán)數(shù)、平均環(huán)數(shù)和命中率
sum=0;
average=0;
n=0;
single_score=0;
for m=1:10
h1=normrnd(0,Eh);
r1=normrnd(0,Er);
h2=normrnd(0,Bh);
r2=normrnd(0,Br);
h=(h1+h2)*10;
r=(r1+r2)*10;
%添加聲音,其實是我自己錄的音
[y,fs]=wavread(’
ak47.wav
’);
sound(y,fs);
switch fix(4*sqrtm(h.^2+r.^2))
case {0,1,2}
sum=sum+10;
n=n+1;
single_score=10;
axes(handles.target);
plot(h,r,’
+
’);
case {3,4,5,6}
sum=sum+9;
n=n+1;
single_score=9;
axes(handles.target);
plot(h,r,’
+
’);
case {7,8,9,10}
sum=sum+8;
n=n+1;
single_score=8;
axes(handles.target);
plot(h,r,’
+
’);
case {11,12,13,14}
sum=sum+7;
n=n+1;
single_score=7;
axes(handles.target);
plot(h,r,’
+
’);
case {15,16,17,18}
sum=sum+6;
n=n+1;
single_score=6;
axes(handles.target);
plot(h,r,’
+
’);
otherwise
sum=sum;
n=n;
single_score=0;
end
%輸出單詞的結(jié)果
switch m
case 1
set(handles.out1,’
string
’,num2str(single_score));
case 2
set(handles.out2,’
string
’,num2str(single_score));
case 3
set(handles.out3,’
string
’,num2str(single_score));
case 4
set(handles.out4,’
string
’,num2str(single_score));
case 5
set(handles.out5,’
string
’,num2str(single_score));
case 6
set(handles.out6,’
string
’,num2str(single_score));
case 7
set(handles.out7,’
string
’,num2str(single_score));
case 8
set(handles.out8,’
string
’,num2str(single_score));
case 9
set(handles.out9,’
string
’,num2str(single_score));
case 10
set(handles.out10,’
string
’,num2str(single_score));
end
pause(1);
end
average=sum/10;
score=10*n;
%顯示總環(huán)數(shù),平均環(huán)數(shù)和命中率
set(handles.sum_output,’
string
’,num2str(sum));
set(handles.average_output,’
string
’,num2str(average));
set(handles.n_output,’
string
’,num2str(score));
%彈出對話框,提示仿真完畢
helpdlg(’
仿真結(jié)束
’,’
提示
’);
% --- Executes on button press in clear.
function clear_Callback(hObject, eventdata, handles)
% hObject handle to clear (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%畫靶子
draw;
%清除輸出結(jié)果
set(handles.sum_output,’
string
’,’
’);
set(handles.average_output,’
string
’,’
’);
set(handles.n_output,’
string
’,’
’);
set(handles.out1,’
string
’,’
’);
set(handles.out2,’
string
’,’
’);
set(handles.out3,’
string
’,’
’);
set(handles.out4,’
string
’,’
’);
set(handles.out5,’
string
’,’
’);
set(handles.out6,’
string
’,’
’);
set(handles.out7,’
string
’,’
’);
set(handles.out8,’
string
’,’
’);
set(handles.out9,’
string
’,’
’);
set(handles.out10,’
string
’,’
’);
function out1_Callback(hObject, eventdata, handles)
% hObject handle to out1 (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 out1 as text
% str2double(get(hObject,’
String
’)) returns contents of out1 as a double
% --- Executes during object creation, after setting all properties.
function out1_CreateFcn(hObject, eventdata, handles)
% hObject handle to out1 (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 && isequal(get(hObject,’
BackgroundColor
’), get(0,’
defaultUicontrolBackgroundColor
’))
set(hObject,’
BackgroundColor
’,’
white
’);
end
function out2_Callback(hObject, eventdata, handles)
% hObject handle to out2 (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 out2 as text
% str2double(get(hObject,’
String
’)) returns contents of out2 as a double
% --- Executes during object creation, after setting all properties.
function out2_CreateFcn(hObject, eventdata, handles)
% hObject handle to out2 (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 && isequal(get(hObject,’
BackgroundColor
’), get(0,’
defaultUicontrolBackgroundColor
’))
set(hObject,’
BackgroundColor
’,’
white
’);
end
function out3_Callback(hObject, eventdata, handles)
% hObject handle to out3 (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 out3 as text
% str2double(get(hObject,’
String
’)) returns contents of out3 as a double
% --- Executes during object creation, after setting all properties.
function out3_CreateFcn(hObject, eventdata, handles)
% hObject handle to out3 (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 && isequal(get(hObject,’
BackgroundColor
’), get(0,’
defaultUicontrolBackgroundColor
’))
set(hObject,’
BackgroundColor
’,’
white
’);
end
function out4_Callback(hObject, eventdata, handles)
% hObject handle to out4 (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 out4 as text
% str2double(get(hObject,’
String
’)) returns contents of out4 as a double
3 仿真結(jié)果
4 參考文獻
博主簡介:擅長智能優(yōu)化算法、神經(jīng)網(wǎng)絡(luò)預(yù)測、信號處理、元胞自動機、圖像處理、路徑規(guī)劃、無人機等多種領(lǐng)域的Matlab仿真,相關(guān)matlab代碼問題可私信交流。
部分理論引用網(wǎng)絡(luò)文獻,若有侵權(quán)聯(lián)系博主刪除。
-
2023年各省最新電價一覽!8省中午執(zhí)行谷段電價! 2023-01-03
-
PPT導(dǎo)出高分辨率圖片的四種方法 2022-09-22
-
2023年最新!國家電網(wǎng)27家省級電力公司負(fù)責(zé)人大盤點 2023-03-14
-
全國消防救援總隊主官及簡歷(2023.2) 2023-02-10
-
盤點 l 中國石油大慶油田現(xiàn)任領(lǐng)導(dǎo)班子 2023-02-28
-
我們的前輩!歷屆全國工程勘察設(shè)計大師完整名單! 2022-11-18
-
關(guān)于某送變電公司“4·22”人身死亡事故的快報 2022-04-26
