Scatter() working but not Plot()

조회 수: 10 (최근 30일)
Kateri Kaminski
Kateri Kaminski 2018년 11월 1일
댓글: Kateri Kaminski 2018년 11월 5일
Hello,
I am having trouble getting plot() to work. My code works if I use scatter() instead of plot(). If I used plot(), then I get Error in plot(x,y). Can someone please tell me why plot is not working? Thanks!
x = 1:10;
y = x.^2;
figure
hold on
plot(x,y)
hold off
  댓글 수: 6
Walter Roberson
Walter Roberson 2018년 11월 2일
My guess is that there is a variable named plot
Kateri Kaminski
Kateri Kaminski 2018년 11월 2일
This is the full error. I am not sure why there is an indexing issue.
>> PostProcessing_filetest
Index exceeds matrix dimensions.
Error in PostProcessing_filetest (line 287)
plot(x,y)

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

채택된 답변

madhan ravi
madhan ravi 2018년 11월 2일
편집: madhan ravi 2018년 11월 2일
Delete another .m file which has the same name plot.m or rename it
  댓글 수: 9
Stephen23
Stephen23 2018년 11월 3일
"That makes sense. Do you know why scatter() works then? This loop is the first time I am using plot() so I am not sure why that would be any different than scatter()."
Because you created a variable named plot, but did not create a variable named scatter.
Kateri Kaminski
Kateri Kaminski 2018년 11월 5일
Ok thanks

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by