20 views (last 30 days)

Show older comments

Hello

I have plotted a vector which has 3 planes.. When I integrate the integral is 0. There are negative regions, yet I expect a number. I us

sd = trapz((z),0,20)

sd =

0

will someone tell me if there is an error with my use of trapz?

sr

Star Strider
on 28 Jul 2021

There quite definitely is!

In your call to it:

sd = trapz((z),0,20)

the function interprets ‘z’ (the parentheses aren’t necessary) as the indepdent variable ‘x’, 0 as the dependent variable ‘y’, and 20 as the dimension. Integrating 0 produces 0 as the result.

.

Star Strider
ungefär 19 timmar ago

I still do not understand this Comment. I have no idea how those results were calculated, so I cannot help with the code to get the desired result.

What integrand produced that integrated result? What were the limits of integration?

Post that code and I will see if I can produce the desired result. Note that the elements of that vector are all functions of ‘x’ so the integral must have been with respect to a different variable.

.

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

Start Hunting!