MATLAB Answers


Scatter() working but not Plot()

Asked by Kateri Kaminski on 1 Nov 2018
Latest activity Commented on by Kateri Kaminski on 5 Nov 2018
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;
hold on
hold off


on 2 Nov 2018
I suspect...he have another function on the name plot. He is not using inbuilt function plot. What does which plot display?
My guess is that there is a variable named plot
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)

Sign in to comment.


1 Answer

Answer by madhan ravi
on 2 Nov 2018
Edited by madhan ravi
on 2 Nov 2018
 Accepted Answer

Delete another .m file which has the same name plot.m or rename it


You can attach the script.
"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.
Ok thanks

Sign in to comment.