HOw to find displacement integrating velocity?
Ältere Kommentare anzeigen
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 Kommentare
Shivam Gothi
am 8 Nov. 2024
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 ?
Riccardo
am 10 Nov. 2024
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Programming finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


