Trapezium Rule value not correct
Mostra commenti meno recenti
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 Commenti
Geoff Hayes
il 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
il 30 Apr 2014
What code is there (in ni2.m) to plot the steps? I just see code to plot the function.
beth
il 30 Apr 2014
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!