首页 > 行业资讯 > 【气动学】基于龙格库塔算法实现外弹道仿真含Matlab源码

【气动学】基于龙格库塔算法实现外弹道仿真含Matlab源码

时间:2022-07-24 来源: 浏览:

【气动学】基于龙格库塔算法实现外弹道仿真含Matlab源码

天天Matlab 天天Matlab
天天Matlab

TT_Matlab

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,完整matlab代码或者程序定制加qq1575304183。

收录于合集 #物理应用matlab源码 45个

1 简介

文着重介绍弹丸外弹道运动轨迹仿真分析,得出弹丸质点运动方程和榴弹刚体弹道方程;运用Matlab软件代入初始值用龙格-库塔进行仿真分析,仿真结果与弹道表进行对比,误差在5%以内。表明弹丸质点弹道仿真结果与弹道表基本吻合,仿真具有一定的参考意义。

2 部分代码

function comet3m(varargin) %COMET3 3 -D Comet-like trajectories. % COMET3(Z) displays an animated three dimensional plot of the vector Z. % COMET3(X,Y,Z) displays an animated comet plot of the curve through the % points [X(i),Y(i),Z(i)]. % COMET3(X,Y,Z,p) uses a comet of length p*length(Z). Default is p = 0 . 1 . % % COMET3(AX,...) plots into AX instead of GCA. % % Example: % t = - pi: pi/ 500 :pi ; % comet3(sin( 5 *t),cos( 3 *t),t) % % See also COMET. % Charles R. Denham, MathWorks, 1989 . % Revised 2 - 9 - 92 , LS and DTP; 8 - 18 - 92 , 11 - 30 - 92 CBM. % Copyright 1984 - 2006 The MathWorks, Inc. % $Revision: 5.11 . 4.4 $ $Date: 2011 / 03 /09 07 : 03 : 36 $ % Parse possible Axes input [ax,args,nargs] = axescheck(varargin{ : }); error(nargchk( 1 , 10 ,nargs, ’struct’ )); % Parse the rest of the inputs if nargs < 2 , x = args{ 1 }; end if nargs == 2 , y = args{ 2 }; end if nargs < 3 , z = x; x = 1 :length (z); y = 1 :length (z); end if nargs == 3 , [x,y,z] = deal(args{ : }); end if nargs < 4 , p = 0 . 10 ; end if nargs == 4 , [x,y,z,p] = deal(args{ : }); end if nargs == 10 , [x,y,z,vx,vy,vz,ph,fy,hg,p] = deal(args{ : }); end if ~isscalar(p) || ~isreal(p) || p < 0 || p >= 1 error(message( ’MATLAB:comet3:InvalidP’ )); end ax = newplot(ax); if ~ishold(ax), [minx,maxx] = minmax(x); [miny,maxy] = minmax(y); [minz,maxz] = minmax(z); axis(ax,[minx maxx miny maxy minz maxz]) end co = get(ax, ’colororder’ ); grid on if size(co, 1 )>= 3 , % Choose first three colors for head, body, and tail head = line( ’parent’ ,ax, ’color’ ,co( 1 , : ), ’marker’ , ’.’ , ’MarkerSize’ , 20 , ’erase’ , ’xor’ , ... ’xdata’ ,x( 1 ), ’ydata’ ,y( 1 ), ’zdata’ ,z( 1 )); body = line( ’parent’ ,ax, ’color’ ,co( 2 , : ), ’linestyle’ , ’-’ , ’erase’ , ’none’ , ... ’xdata’ ,[], ’ydata’ ,[], ’zdata’ ,[]); tail = line( ’parent’ ,ax, ’color’ ,co( 3 , : ), ’linestyle’ , ’-’ , ’erase’ , ’none’ , ... ’xdata’ ,[], ’ydata’ ,[], ’zdata’ ,[]); else % Choose first three colors for head, body, and tail head = line( ’parent’ ,ax, ’color’ ,co( 1 , : ), ’marker’ , ’.’ , ’MarkerSize’ , 20 , ’erase’ , ’xor’ , ... ’xdata’ ,x( 1 ), ’ydata’ ,y( 1 ), ’zdata’ ,z( 1 )); body = line( ’parent’ ,ax, ’color’ ,co( 1 , : ), ’linestyle’ , ’--’ , ’erase’ , ’none’ , ... ’xdata’ ,[], ’ydata’ ,[], ’zdata’ ,[]); tail = line( ’parent’ ,ax, ’color’ ,co( 1 , : ), ’linestyle’ , ’-’ , ’erase’ , ’none’ , ... ’xdata’ ,[], ’ydata’ ,[], ’zdata’ ,[]); end mm = length(z); k = round(p*mm); TIME= 0 ; try % Grow the body % for i = 2 :k+ 1 % j = i- 1 :i ; % set(head, ’xdata’ ,x(i), ’ydata’ ,y(i), ’zdata’ ,z(i)) % set(body, ’xdata’ ,x(j), ’ydata’ ,y(j), ’zdata’ ,z(j)) % drawnow % % end % Primary loop % h =waitbar( 0 , ’Please wait...’ ); % set(h, ’name’ , ’仿真进度’ ); tic; m = length(x); for i = 2 :m j = i- 1 :i ; set(head, ’xdata’ ,x(i), ’ydata’ ,y(i), ’zdata’ ,z(i)) set(body, ’xdata’ ,x(j), ’ydata’ ,y(j), ’zdata’ ,z(j)) %set(tail, ’xdata’ ,x(j-k), ’ydata’ ,y(j-k), ’zdata’ ,z(j-k)) drawnow t = toc; str = format_time(TIME + t); set(findobj( ’tag’ , ’txt_shijian’ ), ’String’ , str); %toc 停止计数,设置显示格式,在display 显示结果 set(findobj( ’tag’ , ’txt_feixinggaodu’ ), ’String’ , z(i)); set(findobj( ’tag’ , ’txt_vx’ ), ’String’ , vx(i)); set(findobj( ’tag’ , ’txt_vy’ ), ’String’ , vy(i)); set(findobj( ’tag’ , ’txt_vz’ ), ’String’ , vz(i)); set(findobj( ’tag’ , ’txt_hesudu’ ), ’String’ , sqrt(vx(i)*vx(i)+vy(i)*vy(i)+vz(i)*vz(i))); set(findobj( ’tag’ , ’txt_pianhang’ ), ’String’ , ph(i)); set(findobj( ’tag’ , ’txt_fuyang’ ), ’String’ , fy(i)); set(findobj( ’tag’ , ’txt_henggun’ ), ’String’ , hg(i)); set(findobj( ’tag’ , ’txt_weizhizuobiao’ ), ’String’ , [ ’(’ num2str(x(i)) ’,’ num2str(z(i)) ’,’ num2str(y(i)) ’)’ ]); % waitbar(i/m,h,[num2str(i* 100 /m) ’%’ ]); end % Clean up the tail for i = m+ 1 :m+k j = i- 1 :i ; set(tail, ’xdata’ ,x(j-k), ’ydata’ ,y(j-k), ’zdata’ ,z(j-k)) drawnow end catch E if ~strcmp(E.identifier, ’MATLAB:class:InvalidHandle’ ) rethrow(E); end end % same subfunction as in comet function [minx,maxx] = minmax(x) minx = min(x(isfinite(x))); maxx = max(x(isfinite(x))); if minx == maxx minx = maxx- 1 ; maxx = maxx+ 1 ; end function str = format_time(t) hrs = floor(t/ 3600 ); min = floor(t/ 60 - 60 *hrs); sec = t - 60 *(min + 60 *hrs); if hrs < 10 h = sprintf( ’0%1.0f:’ , hrs); else h = sprintf( ’%1.0f:’ , hrs); end if min < 10 m = sprintf( ’0%1.0f:’ , min); else m = sprintf( ’%1.0f:’ , min); end if sec < 9.9995 s = sprintf( ’0%1.3f’ , sec); else s = sprintf( ’%1.3f’ , sec); end str = [h m s];

3 仿真结果

4 参考文献

[1]董理赢;王志军;焦志刚;王少宏;. 基于Matlab对弹丸外弹道运动轨迹仿真分析[C]// OSEC首届兵器工程大会论文集. 2017.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

版权:如无特殊注明,文章转载自网络,侵权请联系cnmhg168#163.com删除!文件均为网友上传,仅供研究和学习使用,务必24小时内删除。
相关推荐