Trapezium Rule value not correct
Mostrar comentarios más antiguos
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 comentarios
Geoff Hayes
el 30 de Abr. de 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
el 30 de Abr. de 2014
What code is there (in ni2.m) to plot the steps? I just see code to plot the function.
beth
el 30 de Abr. de 2014
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!