Effacer les filtres
Effacer les filtres

Calculation of a given area using the trapz

4 vues (au cours des 30 derniers jours)
Jacqueline Rigatto
Jacqueline Rigatto le 2 Déc 2020
Commenté : Jon le 2 Déc 2020
Hello, to calculate the total area I used the trapz and it worked, but I can't do it for a certain area (figure above inside the red rectangle). If you can calculate, do I use trapz or do I use another? Show me how you do, please.
Thanks

Réponse acceptée

Jon
Jon le 2 Déc 2020
Modifié(e) : Jon le 2 Déc 2020
You need to limit the range of x and y that are fed to trapz, you could do something like this, assuming your original variables are called x and y (modify accordingly for your actual variable names)
% assume x and y are defined earlier
% define range of interest
xRange = [21,31.3]
% find logical indices for range of interest
idl = x >= xRange(1) & x <= xRange(2);
% provide just values of interest to trapz
A = trapz(x(idl),y(idl))
  2 commentaires
Jacqueline Rigatto
Jacqueline Rigatto le 2 Déc 2020
Thanks for the help, Jon
Jon
Jon le 2 Déc 2020
Your welcome

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differentiation 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