【氣動(dòng)學(xué)】基于龍格庫塔算法實(shí)現(xiàn)外彈道仿真含Matlab源碼
【氣動(dòng)學(xué)】基于龍格庫塔算法實(shí)現(xiàn)外彈道仿真含Matlab源碼
TT_Matlab
博主簡介:擅長智能優(yōu)化算法、神經(jīng)網(wǎng)絡(luò)預(yù)測、信號處理、元胞自動(dòng)機(jī)、圖像處理、路徑規(guī)劃、無人機(jī)等多種領(lǐng)域的Matlab仿真,完整matlab代碼或者程序定制加qq1575304183。
1 簡介
文著重介紹彈丸外彈道運(yùn)動(dòng)軌跡仿真分析,得出彈丸質(zhì)點(diǎn)運(yùn)動(dòng)方程和榴彈剛體彈道方程;運(yùn)用Matlab軟件代入初始值用龍格-庫塔進(jìn)行仿真分析,仿真結(jié)果與彈道表進(jìn)行對比,誤差在5%以內(nèi)。表明彈丸質(zhì)點(diǎn)彈道仿真結(jié)果與彈道表基本吻合,仿真具有一定的參考意義。
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’
,
’仿真進(jìn)度’
);
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 停止計(jì)數(shù),設(shè)置顯示格式,在display 顯示結(jié)果
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 仿真結(jié)果
4 參考文獻(xiàn)
[1]董理贏;王志軍;焦志剛;王少宏;. 基于Matlab對彈丸外彈道運(yùn)動(dòng)軌跡仿真分析[C]// OSEC首屆兵器工程大會論文集. 2017.
博主簡介:擅長智能優(yōu)化算法、神經(jīng)網(wǎng)絡(luò)預(yù)測、信號處理、元胞自動(dòng)機(jī)、圖像處理、路徑規(guī)劃、無人機(jī)等多種領(lǐng)域的Matlab仿真,相關(guān)matlab代碼問題可私信交流。
部分理論引用網(wǎng)絡(luò)文獻(xiàn),若有侵權(quán)聯(lián)系博主刪除。
-
2023年各省最新電價(jià)一覽!8省中午執(zhí)行谷段電價(jià)! 2023-01-03
-
PPT導(dǎo)出高分辨率圖片的四種方法 2022-09-22
-
全國消防救援總隊(duì)主官及簡歷(2023.2) 2023-02-10
-
盤點(diǎn) l 中國石油大慶油田現(xiàn)任領(lǐng)導(dǎo)班子 2023-02-28
-
我們的前輩!歷屆全國工程勘察設(shè)計(jì)大師完整名單! 2022-11-18
-
關(guān)于某送變電公司“4·22”人身死亡事故的快報(bào) 2022-04-26
