Graph will not display

조회 수: 11 (최근 30일)
panacean
panacean 2018년 1월 25일
댓글: panacean 2018년 1월 25일
the program is still in the early stages, so quite abit of it is commented out. My loop is running through with no errors, but I'm not getting the graph to display. Any thoughts on why would be appreciated. I attached the file below.

채택된 답변

Walter Roberson
Walter Roberson 2018년 1월 25일
Change
plot(x2,fx)
to
plot(x2, fx, '*')
  댓글 수: 3
Walter Roberson
Walter Roberson 2018년 1월 25일
You have
x2=1:number;
so x2 is a vector.
You have
while x2 < number
Here x2 is a vector. In MATLAB, this test is the same as
while all(x2 < number)
-- the body of the while is only executed if all elements of the vector x2 are < number. But some of them are not.
Perhaps you should be using a for loop instead of a while loop.
panacean
panacean 2018년 1월 25일
Worked like a charm, thanks for the help.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by