HOw to find displacement integrating velocity?
45 次查看(过去 30 天)
显示 更早的评论
Hi, i need to find the displacement of a moving object x(t) knowing its velocity as a function of the displacement itself v(x). The function i have used is the following
I imposed that dx / dt = v(x) and then I tryed to use ODE 45 to find x(t) but I always get a vector full of zeros but i can't understand where the mistake is. This is the code that I wrote:
%% data
Po=1.5; % [bar] absolute feeding pressure
P1=1.01315; % [bar] absolute atmosferic pressure
rho=2700; %[kg/m^3] projectile density
D=0.048; % [m] projectile diameter
Length=0.10; % [m] projectile length
A=(pi/4)*D.^2; % [m^2] projectile face area
m=rho*A*Length; % [kg] projectile mass
L=0.90; %[m] useful barrell length
L_d=0.4; %[m] decelleration barrel length
Vol=0.0095; %[m^3] chamber volume
gamma=1.4; % air constant
% friction forces with 0.47 friction coefficient between aluminium and% steel
f=0.47*m*9.81;
%% model
x_dot=@(t,x) sqrt((2./m).*((Po.*1e5.*Vol)./(gamma-1).*(1-(Vol./(A.*x+Vol)).^(gamma-1))-A.*x.*P1.*1e5-x.*f));
x0=0;
tspan=0:0.1:1;
[t,x]=ode45(x_dot,tspan,x0);
plot(t,x)
3 个评论
Shivam Gothi
2024-11-8,10:15
can you please explain in brief what does this equation do? which system dynamics does it represents ?
I am getting some non-zero imaginery solution for velocity if I put "x0=1".
This is because, I found that the value of expression inside the sqrt() function is coming out to be negative (for positive "x", take x=1 as an example).
So sqrt() applied on negative number gives imaginary value. What does the imaginery "x_dot" represent here ?
采纳的回答
Torsten
2024-11-10,19:09
编辑:Torsten
2024-11-10,19:36
The equation from above describes the stationary velocity profile over the length L. Thus replacing v by dx/dt does not make sense in this case because there is no movement of x: x is the static position over the length L.
Or do you try to compute the position of a massless particle moving in x-direction over time ? Then use
%% data
Po=1.5; % [bar] absolute feeding pressure
P1=1.01315; % [bar] absolute atmosferic pressure
rho=2700; %[kg/m^3] projectile density
D=0.048; % [m] projectile diameter
Length=0.10; % [m] projectile length
A=(pi/4)*D.^2; % [m^2] projectile face area
m=rho*A*Length; % [kg] projectile mass
L=0.90; %[m] useful barrell length
L_d=0.4; %[m] decelleration barrel length
Vol=0.0095; %[m^3] chamber volume
gamma=1.4; % air constant
% friction forces with 0.47 friction coefficient between aluminium and% steel
f=0.47*m*9.81;
%% model
x_dot=@(t,x) sqrt((2./m).*((Po.*1e5.*Vol)./(gamma-1).*(1-(Vol./(A.*x+Vol)).^(gamma-1))-A.*x.*P1.*1e5-x.*f));
x0=1e-8;
tspan=0:0.01:1;
options = odeset('Events',@(t,x)event(t,x,L));
[t,x]=ode45(x_dot,tspan,x0,options);
plot(x,t)
xlabel('Length')
ylabel('Time')
grid on
function [position,isterminal,direction] = event(t,x,L)
position = x(1)-L; % The value that we want to be zero
isterminal = 1; % Halt integration
direction = 0; % The zero can be approached from either direction
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!