Effacer les filtres
Effacer les filtres

Numerical integration using cumtrapz

6 vues (au cours des 30 derniers jours)
Somnath Kale
Somnath Kale le 17 Fév 2021
Commenté : Star Strider le 19 Fév 2021
how to add upper and lower limits in cumtrpz function?

Réponse acceptée

Star Strider
Star Strider le 17 Fév 2021
The cumtrapz function integrates a vector, and ideally, the dependent variable vector with respect to the independent variable vector.
The limits of the independent variable vector are the limits of the integration, so for example:
x = 0:42;
y = randn(size(x));
Int_y_dx = cumtrapz(x, y);
figure
yyaxis left
plot(x, y)
ylabel('$y(x)$', 'Interpreter','latex')
yyaxis right
plot(x, Int_y_dx)
ylabel(sprintf('$\\int_{%d}^{%d}y(x)\\ dx$',min(x),max(x)), 'Interpreter','latex', 'FontSize',14)
grid
xlim([min(x) max(x)])
.
  2 commentaires
Somnath Kale
Somnath Kale le 19 Fév 2021
Thank you!! @Star Strider
Star Strider
Star Strider le 19 Fév 2021
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur NaNs dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by