Why my graph only contain 4 lines instead of 6 lines

2 vues (au cours des 30 derniers jours)
Dan
Dan le 6 Juin 2023
Commenté : Dan le 6 Juin 2023
I defined a function which is calculate_pi, and using 6 different method to approxiamt the value of pi. The compute answer is correct, but when I use the answer to calculate the error between the value of pi in matlab, and plot the error in graph, it only shows 4 lines instead of 6 lines. I don't know why, can somebody help me? I appreciate that!
  1 commentaire
VBBV
VBBV le 6 Juin 2023

Can you share the code for function calculate_pi instead of snapshot ?

Connectez-vous pour commenter.

Réponse acceptée

Nathan Hardenberg
Nathan Hardenberg le 6 Juin 2023
Modifié(e) : Nathan Hardenberg le 6 Juin 2023
Check if your err-array for "left-hand" and "right-hand" has values in it. If thy are NaN, it does not plot a line, but no error is thrown
-- EDIT -- (after calculate_pi() Code)
Three of your methods result in the same graph ("left_end", "right_end" and "trapezoidal"). Thats why you are only able to see four graphs. I plotted with different linestyles to make it more obvious.
  1 commentaire
Dan
Dan le 6 Juin 2023
Thank you so much. I wonder if it's correct that they have the same value?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by