Can you share the code for function calculate_pi instead of snapshot ?
Why my graph only contain 4 lines instead of 6 lines
2 次查看(过去 30 天)
显示 更早的评论
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!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1403949/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1403954/image.png)
采纳的回答
Nathan Hardenberg
2023-6-6
编辑:Nathan Hardenberg
2023-6-6
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1404579/image.png)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!