time derivative of pressure

5 views (last 30 days)
Simone Pavesi
Simone Pavesi on 30 Nov 2022
Commented: Simone Pavesi on 2 Dec 2022
I have a .txt file with two columns of values: the first is the pressure, the second is the time (at each instant of time I have an assigned value of pressure). I need to calculate the time derivative of the pressure.
P.s: the method like: dpdt = diff(p) / diff(t), with p e t the values of the .txt file, cannot be used since bring to wrong results.
The suggestion was to use backward / forward / central differences, but I do not know how to use.
Thanks!
  10 Comments
Star Strider
Star Strider on 30 Nov 2022
@Simone Pavesi — It works. The data need more precision than is posted —
A = [4.59e-05 5.99978e+06
4.6e-05 5.99977e+06
4.61e-05 5.99977e+06
4.62e-05 5.99977e+06
4.63e-05 5.99977e+06
4.64e-05 5.99977e+06
4.65e-05 5.99977e+06
4.66e-05 5.99977e+06
4.67e-05 5.99977e+06
4.68e-05 5.99977e+06
4.69e-05 5.99977e+06
4.7e-05 5.99977e+06
4.71e-05 5.99977e+06
4.72e-05 5.99977e+06
4.73e-05 5.99977e+06
4.74e-05 5.99977e+06
4.75e-05 5.99977e+06
4.76e-05 5.99977e+06
4.77e-05 5.99977e+06
4.78e-05 5.99977e+06
4.79e-05 5.99976e+06];
dpdt = gradient(A(:,2)) ./ gradient(A(:,1));
figure
yyaxis left
plot(A(:,1), A(:,2))
ylabel('$P(t)$', 'Interpreter','latex')
yyaxis right
plot(A(:,1), dpdt)
ylabel('$\frac{dP(t)}{dt}$', 'Interpreter','latex')
xlabel('$t$', 'Interpreter','latex')
.
Simone Pavesi
Simone Pavesi on 2 Dec 2022
Thank you at all guys!

Sign in to comment.

Answers (0)

Categories

Find more on Dates and Time in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!