Trapezium Rule value not correct
Ältere Kommentare anzeigen
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 Kommentare
Geoff Hayes
am 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
am 30 Apr. 2014
What code is there (in ni2.m) to plot the steps? I just see code to plot the function.
beth
am 30 Apr. 2014
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!