Matlab - Proyectil+Misil,DUDAAAA!!!

 
Vista:
sin imagen de perfil
Val: 1
Ha aumentado su posición en 33 puestos en Matlab (en relación al último mes)
Gráfica de Matlab

Proyectil+Misil,DUDAAAA!!!

Publicado por Sonia (1 intervención) el 21/12/2019 11:13:01
Hola, estoy haciendo un programa en matlab3d, y quisiera simular un antimisiles,quiero que un proyectil haga una parabola y el misil una recta, y vaya calculando los diferentes puntos hasta que se encuentren un mismo punto. y todo esto simulando y hacerlo que se vaya viendo. lo unico que tengo es esto y nose si serviria:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function parabolic_with_friction()
global g k m
close all;
g = 9.81; %m/s^ 2. gravity at equator
% datos de ajustados a 1000 m de
theta0 = 0; %initial angle
k = 0.0000005; % N*s/m friction coefficient
m=9.7/1000; %mass of the bullet kg
v=860; % m/s initial speed
t0 = 0;
tfinal = 1.2;
x0 = 0;
y0 = 0;
vx0 = v*cos(theta0);vy0 = v*sin(theta0);
[t, x] = runge_kutta(@parabolic_friction_square, [x0 y0 vx0 vy0]', [t0
tfinal], 0.01);
x = x(:, 1:length(t));
plot(t, x(1,:), 'r'), hold
plot(t, x(2,:), 'g')
plot(t, x(3,:), 'b')
plot(t, x(4,:), 'c')
legend('Position X (m) RK4', 'Position Y (m) RK4', 'Speed X (m/s)
RK4', 'Speed Y (m/s) RK4')
figure,
plot(x(1,:), x(2,:), 'r')
xlabel('X Position (m)')
ylabel('Y Position (m)')
x(2,end)
function xd = parabolic_friction_square(t, x)
global k g m
% We must return the solution of
% [dx1/dt; dx2/dt; dx3/dt dx4/dt]
vx = x(3);
vy = x(4);
%forces in both axes
sq = sqrt(vx^2+vy^2);
xd(1) = vx;
xd(2) = vy;
xd(3) = -(k/m)*vx*sq;
xd(4) = -(k/m)*vy*sq - g;
xd = xd(:);




NECESITO AYUDA!! Alguien puede decirme como hacerlo o que formulas aplicar. un saludo
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de JOSE JEREMIAS CABALLERO
Val: 6.975
Oro
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

Proyectil+Misil,DUDAAAA!!!

Publicado por JOSE JEREMIAS CABALLERO (5917 intervenciones) el 24/12/2019 14:09:05
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function parabolic_with_friction()
global g k m
close all;
g = 9.81; %m/s^ 2. gravity at equator
% datos de ajustados a 1000 m de
theta0 = 0; %initial angle
k = 0.0000005; % N*s/m friction coefficient
m=9.7/1000; %mass of the bullet kg
v=860; % m/s initial speed
t0 = 0;
tfinal = 1.2;
x0 = 0;
y0 = 0;
vx0 = v*cos(theta0);
vy0 = v*sin(theta0);
[t, x] = ode45(@parabolic_friction_square, [t0 tfinal], [x0 y0 vx0 vy0] );
figure(1)
plot(t, x(:,1), 'r'),
hold on
plot(t, x(:,2), 'g')
plot(t, x(:,3), 'b')
plot(t, x(:,4), 'm')
legend('Position X (m) RK4', 'Position Y (m) RK4', 'Speed X (m/s) RK4', 'Speed Y (m/s) RK4')
hold off
 
figure(2),
plot(x(1,:), x(2,:), 'r')
xlabel('X Position (m)')
ylabel('Y Position (m)')
x(2,end)
 
 
function xd = parabolic_friction_square(t, x)
global k g m
% We must return the solution of
% [dx1/dt; dx2/dt; dx3/dt dx4/dt]
vx = x(3);
vy = x(4);
%forces in both axes
sq = sqrt(vx^2+vy^2);
xd(1) = vx;
xd(2) = vy;
xd(3) = -(k/m)*vx*sq;
xd(4) = -(k/m)*vy*sq - g;
xd = xd(:);

1
>> parabolic_with_friction

Saludos
JOSE JEREMIAS CABALLERO
Asesor de Proyectos con Matlab
Servicios de programación matlab
Servicio de Asesoría Online en Matlab


http://matlabcaballero.blogspot.com
https://www.facebook.com/matlabcaballero
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar