Trapezium Rule value not correct
Show older comments
Hello, I posted on here earlier about a problem with my function but I have managed to fix that problem. However the value for my trapezium rule is wrong and I was wondering what I had done wrong? Also my graph won't create the stairs and steps that I have created, the area underneath the graph is just filled in red instead of creating rectangles unless there is a better way to plot the rectangle rule? I have attached my code to this question, help would be fantastic as the code is due in for hand in on friday and I am very stuck!!!
3 Comments
Geoff Hayes
on 30 Apr 2014
Beth - Were you comparing your output with that from the MATLAB trapz function? Note that if you just input the y vector from your code and run the command as trapz(y) then the result will not match with yours since trapz assumes that unit spacing was used to determine the values of y. Instead, try trapz(x,y) and the answer will be similar to yours.
Geoff Hayes
on 30 Apr 2014
What code is there (in ni2.m) to plot the steps? I just see code to plot the function.
beth
on 30 Apr 2014
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices 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!