Numerical integration of area
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
user20912
am 30 Jul. 2024
Kommentiert: user20912
am 30 Jul. 2024
Hi,
I know this must be so easy but I'm confused. I have a section such as this:
I have both variables depth and distance as vectors:
>> whos depth rotx
Name Size Bytes Class Attributes
depth 69x1 552 double
rotx 69x1 552 double
What is the right way to compute the section area?
Thanks!
0 Kommentare
Akzeptierte Antwort
John D'Errico
am 30 Jul. 2024
Bearbeitet: John D'Errico
am 30 Jul. 2024
The region in color? The integral will be negative, or course, since depth is entirely negative.
But you perform such an integration using trapz. The integration you need to do is the difference between the lower limit at any x, and the upper limit, which is 0. As such,
trapz(depth,0-rotx) % Not this, of course.
Read the help for trapz.
Edit: (Duh) Repairing my sleepy code:
trapz(rotx,0-depth)
3 Kommentare
John D'Errico
am 30 Jul. 2024
Bearbeitet: John D'Errico
am 30 Jul. 2024
Of course, I did. Is that not what I wrote? ;-)
I admit, I always forget, since trapz tries to be tricky. You can call it with 1 or 2 arguments. With 2 arguments, you call it as trapz(x,y), but with only one argument, it is just trapz(y). Personally, I never liked the way they did it.
help trapz
So, yes. I meant to write
trapz(rotx,0-depth)
And apparently, my fingers got in the way of my head.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differentiation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!