Why isn't a line showing on my graph?

조회 수: 2 (최근 30일)
Bella Finkel
Bella Finkel 2015년 12월 7일
댓글: Star Strider 2015년 12월 7일
I tried graphing using plot(x, y, '-r') and it just put out a blank sheet. Is there something else I have to use to actually graph something?
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2015년 12월 7일
Bella - no, there is nothing else that you need to do to plot your graph. What can you tell us about x and y. Are these scalars or arrays? Try plotting
plot(x,y,'ro')
instead as that will put a red circle at your coordinates and so will be easier to see.
Star Strider
Star Strider 2015년 12월 7일

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

답변 (1개)

Walter Roberson
Walter Roberson 2015년 12월 7일
Typically when that happens the person has the plot(x,y,'-r') in a loop with x and y being scalars. plot() will only create lines between the plots that are present in the same plot() call. The solution in such cases is to store the x and y values in a vector and do the plot after the loop.
for K = 1 : number_of_iterations
...
x_vector(K) = x;
y_vector(K) = y;
end
plot(x_vector, y_vector, '-r')

카테고리

Help CenterFile Exchange에서 Networks에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by