How does the pressure change with time?

조회 수: 6 (최근 30일)
sanjeet mansoor
sanjeet mansoor 2022년 7월 9일
편집: Sam Chak 2022년 7월 12일
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.
% Define System parameters
Force = 100; % input force 100 N
m = 50; % mass 50 kg
c = 1000; % friction constant 1000 Ns/m
A = .02; % 0.02 m2
dt = .001; % fixed time step of 1 millisecond
ts = 0; % simulation start time
tf = 2; % simulation end time
t = ts:dt:tf; % simulation time vector [0 .001 .002 ... 50]
x = zeros(size(t)); % displacement vector [0 0 0 ...]
xddot = ones(size(t));
xdot = zeros(size(t)); % Velocity vector [0 0 0 ...]
f = Force*ones(size(t)); % force vector [10 10 10 ...]
xddot(1) = 1/m*(f(1)); % initial value for acceleration
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
%Dis plot
subplot(311)
plot(t,x)
% Velocity plot
subplot(312)
plot(t,xdot)
% Acceleration plot
subplot(313)
plot(t,xddot)

답변 (1개)

Sam Chak
Sam Chak 2022년 7월 10일
I'm unfamiliar with your Hydraulic system. If the system is correctly described by the following equation
then the simulation probably looks like this:
tspan = linspace(0, 2, 2001);
x0 = [0.1 0]; % initial displacement
[t, x] = ode45(@odefcn, tspan, x0);
plot(t, x(:, 1)), grid on, xlabel('t')
function dxdt = odefcn(t, x)
dxdt = zeros(2, 1);
Load = 100; % Force due to Load 100 N
m = 50; % Mass 50 kg
c = 1000; % Friction constant 1000 Ns/m
A = 0.02; % Area 0.02 m2
omega = 6; % adjust this parameter (increase for faster response)
P1 = (- 2*m*omega*x(2) - m*(omega^2)*x(1) + c*x(2))/A; % Pressure if Load is unknown
P2 = (- 2*m*omega*x(2) - m*(omega^2)*x(1) - Load + c*x(2))/A; % Pressure if Load is known
dxdt(1) = x(2);
dxdt(2) = (A*P2 + Load - c*x(2))/m; % Decide either P1 or P2
end
  댓글 수: 2
sanjeet mansoor
sanjeet mansoor 2022년 7월 11일
sorry, the pressure starts at 10000 and ends at 5000 Pa. I tried changing x0, but im not sure what that is.
Sam Chak
Sam Chak 2022년 7월 12일
편집: Sam Chak 2022년 7월 12일
@sanjeet mansoor, no worries. But I don't see anywhere in the equations provided by you, can enter the initial pressure 10 kPa and the final pressure 5 kPa. Unless this is a Boundary-Value Problem (BVP).
If you merely want to plot the Time vs. Pressure graph, then you should provide the formula/equation for the Pressure as a function of Time. That's Simple and Direct.
If you want to fix Pa, Pa, and make the pressure to decrease linearly over time, that is also possible.
Anyhow, you must describe your problem in clarity. If you don't understand a particular part of the problem, then also need to describe the specific part you don't understand in clarity.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Linear Least Squares에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by