Attached is the question. I believe this is how I would set up the equation. At timestep 0 = xdot = 0
This is the initial code that I have but I need to get pressure vs time graph.
Force = 100;
m = 50;
c = 1000;
A = .02;
dt = .001;
ts = 0;
tf = 2;
t = ts:dt:tf;
x = zeros(size(t));
xddot = ones(size(t));
xdot = zeros(size(t));
f = Force*ones(size(t));
xddot(1) = 1/m*(f(1));
for i = 1:length(t)-1
x(i+1) = xdot(i)*dt + x(i);
xdot(i+1) = xddot(i)*dt + xdot(i);
xddot(i+1) = 1/m*(f(i+1) - c*xdot(i));
end
subplot(311)
plot(t,x)
subplot(312)
plot(t,xdot)
subplot(313)
plot(t,xddot)