Why my graph only contain 4 lines instead of 6 lines

조회 수: 7 (최근 30일)
Dan
Dan 2023년 6월 6일
댓글: Dan 2023년 6월 6일
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
VBBV
VBBV 2023년 6월 6일

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

댓글을 달려면 로그인하십시오.

채택된 답변

Nathan Hardenberg
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.
  댓글 수: 1
Dan
Dan 2023년 6월 6일
Thank you so much. I wonder if it's correct that they have the same value?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by