【图像处理】打靶仿真系统【含GUI Matlab源码 1043期】

本文详细描述了一位Matlab爱好者在开发打靶仿真系统过程中的经历,包括模型构建、程序难点(如音频文件添加)、GUI设计以及MATLAB2014a版本的使用。作者分享了遇到的问题和解决方案,展示了学习和实践中的成长过程。
摘要由CSDN通过智能技术生成

✅博主简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,Matlab项目合作可私信。
🍎个人主页:海神之光
🏆代码获取方式:
海神之光Matlab王者学习之路—代码获取方式
⛳️座右铭:行百里者,半于九十。

更多Matlab仿真内容点击👇
Matlab图像处理(进阶版)
路径规划(Matlab)
神经网络预测与分类(Matlab)
优化求解(Matlab)
语音处理(Matlab)
信号处理(Matlab)
车间调度(Matlab)

⛄一、打靶仿真系统简介

1 课题描述
在这里插入图片描述
2 课题建模过程
a)第一,获取武器的各个参数,并且由这些参数计算武器在方向和高低上的响应公算偏差;
b)第二,射击过程中方向和高低上的偏差呈正态分布。在matlab中取normrnd函数实现改功能(其中,标准差为共算误差);
c)第三,根据计算值,在靶上作出击中点:靶子的10环半径是0.75m,9环半径是1.75m,以此类推,6环半径是4.75m,6环之外均记为0环,输出每次射击的成绩;
d)第四,计算总环数、平均环数和命中率,命中率为6环以上占10枪的比例。
三、课题实现出现的关键难点
a)刚开始做的时候入手难
由于上课听课不认真,说实话,一开始做程序没法入手,完全不知道该如何进展。
在这种情况下,我先买了一本参考书,并对参考书中仅有的一个实例进行了试验。虽然是完全照抄,但过程中也碰到了不少麻烦,书中有几个对象的tag前后不一致,使得程序无法运行。看了一下书,仔细琢磨后,修改了程序,并成功运行。在这过程中,开始对程序有所了解。
看完GUI那一章,基本上开始有头绪了,然后就开始选定课题,动手设计界面,进行功能上的分析。
选课题的时候也纠结了一下,最后选择了一个4星的题目,确实是因为时间安排上的问题,因为周末还要上双学位的课,平常有什么课也不舍得翘。
b)程序上碰到的问题
因为选题还是蛮简单的,程序上做下来一直很顺利,做图形的时候温习了书中图形的部分,写回调函数的时候温习matlab程序上的一些特点,因为学过c语言,感觉除了matlab有一些特殊的用法,像脚本文件、函数文件,还有几个流程控制语句,其他的都很相似。程序上很快就能上手。
其中碰到几个想实现的功能,如隐去坐标轴、弹出对话框等几个功能,都是上网搜的,经过试验,最后写到了程序当中。
c)声音的添加
这个算是我碰到的比较大的麻烦,加它的时候还以为自己很有创意呢,后来我发现也有同学加了那个功能,但是我在这个过程中确实遇到了很大麻烦。
先有这个想法的时候在网上搜能不能添加背景音乐,发现可以wavread函数,然后在网上找了一段ak47的枪声,没想到这段枪声折腾了我好久。
当然,我知道只能添加.wav格式的音频文件,下载的这段枪声也是.wav格式的,但是怎么也添加不进去。进行调试的时候,进入到wavread函数中,发现了报错跳出来的地方,但是也看不懂。把那一段复制粘贴之后,发现了百度上的一个问题正是关于它的。里面提到有些.wav格式不是标准的格式,可能不能输入到matlab中。我搜索了.wav的内容,确认了这个想法,并下载了转换格式的软件,将这段音频转了n多遍却还是不行。
最后,也是巧合,我在看网页的时候发现windows自带的录音机能够产生标准.wav格式,这就成了我最后的希望。如果这个再不行,我觉得放弃掉加载声音了。当然,最后是成功了。

⛄二、部分源代码

function varargout = target(varargin)
% TARGET M-file for target.fig
% TARGET, by itself, creates a new TARGET or raises the existing
% singleton*.
%
% H = TARGET returns the handle to a new TARGET or the handle to
% the existing singleton*.
%
% TARGET(‘CALLBACK’,hObject,eventData,handles,…) calls the local
% function named CALLBACK in TARGET.M with the given input arguments.
%
% TARGET(‘Property’,‘Value’,…) creates a new TARGET or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before target_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to target_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

% Last Modified by GUIDE v2.5 08-Jue-2021 23:48:24

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct(‘gui_Name’, mfilename, …
‘gui_Singleton’, gui_Singleton, …
‘gui_OpeningFcn’, @target_OpeningFcn, …
‘gui_OutputFcn’, @target_OutputFcn, …
‘gui_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 is made visible.
function target_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 (see VARARGIN)

%画靶子
draw;

% Choose default command line output for target
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes target wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% — Outputs from this function are returned to the command line.
function varargout = target_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

⛄三、运行结果

在这里插入图片描述

⛄四、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1]魏丽芬,陈文印.军事打靶虚拟仿真系统开发研究[J].福建电脑. 2022,38(11)

3 备注
简介此部分摘自互联网,仅供参考,若侵权,联系删除

🍅 仿真咨询
1 各类智能优化算法改进及应用

生产调度、经济调度、装配线调度、充电优化、车间调度、发车优化、水库调度、三维装箱、物流选址、货位优化、公交排班优化、充电桩布局优化、车间布局优化、集装箱船配载优化、水泵组合优化、解医疗资源分配优化、设施布局优化、可视域基站和无人机选址优化

2 机器学习和深度学习方面
卷积神经网络(CNN)、LSTM、支持向量机(SVM)、最小二乘支持向量机(LSSVM)、极限学习机(ELM)、核极限学习机(KELM)、BP、RBF、宽度学习、DBN、RF、RBF、DELM、XGBOOST、TCN实现风电预测、光伏预测、电池寿命预测、辐射源识别、交通流预测、负荷预测、股价预测、PM2.5浓度预测、电池健康状态预测、水体光学参数反演、NLOS信号识别、地铁停车精准预测、变压器故障诊断

3 图像处理方面
图像识别、图像分割、图像检测、图像隐藏、图像配准、图像拼接、图像融合、图像增强、图像压缩感知

4 路径规划方面
旅行商问题(TSP)、车辆路径问题(VRP、MVRP、CVRP、VRPTW等)、无人机三维路径规划、无人机协同、无人机编队、机器人路径规划、栅格地图路径规划、多式联运运输问题、车辆协同无人机路径规划、天线线性阵列分布优化、车间布局优化

5 无人机应用方面
无人机路径规划、无人机控制、无人机编队、无人机协同、无人机任务分配

6 无线传感器定位及布局方面
传感器部署优化、通信协议优化、路由优化、目标定位优化、Dv-Hop定位优化、Leach协议优化、WSN覆盖优化、组播优化、RSSI定位优化

7 信号处理方面
信号识别、信号加密、信号去噪、信号增强、雷达信号处理、信号水印嵌入提取、肌电信号、脑电信号、信号配时优化

8 电力系统方面
微电网优化、无功优化、配电网重构、储能配置

9 元胞自动机方面
交通流 人群疏散 病毒扩散 晶体生长

10 雷达方面
卡尔曼滤波跟踪、航迹关联、航迹融合

  • 17
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值