Is this formula correct for simulate 3D Water rocket
Afficher commentaires plus anciens
I want to simulate 3D Water Rocket only use Acceleration data collected from Sensor GY86
But after I run
The results gave me have a lot of line and isn't correct
I don't know if i use this Calculation is correct or enough or i am missing some steps in formula
I have tried this
function Water_rocket_simulator
clc
close all
clear all
load('Acce and Gyro xyz')
%% CONSTANTS
g = 9.81;
%% INPUT DATA
x = 0;
y = 0;
z = 0;
v0 = 30;
alpha = 90;
t = 0;
dt = 0.01;
%% FIGURE
figure('name','Water Rocket','color','white','numbertitle','off');
hold on
fig_rocket = plot3(x,y,z,'ro','MarkerSize',10,'markerfacecolor','r');
ht = title(sprintf('t = %0.2f s',t));
xlabel('X axis Latitude');
ylabel('Y axis Longtitude');
zlabel('Z axis heights');
grid on
axis equal
axis([1 300 1 300 1 300]);
%% CALCULATION
alpha = alpha/180*pi;
vx = v0*cos(alpha);
vy = v0*cos(alpha);
vz = v0*sin(alpha);
while z>-0.01
t = t+dt;
ax = AccelerationX(:,1)/1000;
ay = AccelerationY(:,1)/1000;
az = AccelerationZ(:,1)/1000;
vx = vx+ax*dt;
vy = vy+ay*dt;
vz = vz+az*dt;
x = x+vx*dt+0.5*ax*dt.^2;
y = y+vy*dt+0.5*ay*dt.^2;
z = z+vz*dt+0.5*az*dt.^2;
plot3(x,y,z,'o','markersize',1,'color','k');
xlabel('X axis Latitude');
ylabel('Y axis Longtitude');
zlabel('Z axis Heights');
grid on
set(fig_rocket,'xdata',x,'ydata',y,'zdata',z);
set(ht,'string',sprintf('t = %0.2f s',t));
pause(0.002);
end
end
1 commentaire
Alan Stevens
le 29 Juin 2021
Perhaps you need something like
for i = 2:numel(AccelerationX)
t(i) = t(i-1) + dt;
ax(i) = Acceleration(i,1)/1000;
% similarly for ay and az
vx(i) = vx(i-1)+ax(i)*dt;
% ...etc
x(i) = x(i-1) + vx(i)*dt +0.5*ax(i)*dt^2;
% ...etc
end
Réponses (1)
Alan Stevens
le 28 Juin 2021
Probably
vy = v0*cos(alpha);
should be more like
vy = v0*cos(alpha)*cos(beta);
where beta is an angle that will point the rocket out of the x-z plane.
1 commentaire
Le Long
le 29 Juin 2021
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
