Scatter() working but not Plot()

11 visualizaciones (últimos 30 días)
Kateri Kaminski
Kateri Kaminski el 1 de Nov. de 2018
Comentada: Kateri Kaminski el 5 de Nov. de 2018
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 comentarios
Walter Roberson
Walter Roberson el 2 de Nov. de 2018
My guess is that there is a variable named plot
Kateri Kaminski
Kateri Kaminski el 2 de Nov. de 2018
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)

Iniciar sesión para comentar.

Respuesta aceptada

madhan ravi
madhan ravi el 2 de Nov. de 2018
Editada: madhan ravi el 2 de Nov. de 2018
Delete another .m file which has the same name plot.m or rename it
  9 comentarios
Stephen23
Stephen23 el 3 de Nov. de 2018
"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 el 5 de Nov. de 2018
Ok thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by