Error using matlab.int​ernal.grap​h.MLGraph.​edgesConst​rWithIndex Source must be a numeric array of positive integer node indices.

Hi,
I am trying to make a simple plot but none of my attempts seems to work. On a main file i use this code
y2=0;
x=-10:0.001:4;
y1=((x+1).^3).*(x-2);
graph(x,y1,y2);
and on file graph.m i use this code
function graph(x,y1,y2)
figure
plot(x,y1,'r-',x,y2,'b-*','MarkerSize',2)
xlabel ( 'x','FontName','Arial','FontSize',10);
ylabel ( 'y','FontName','Arial','FontSize',10);
title( 'Plot y1, y2','FontSize',10 );
When i change the x as following: x=1:0.001:4; another error occurs "Target must be a numeric array of positive integer node indices."
I also get these errors
Error in matlab.internal.graph.constructFromEdgeList (line 220)
[G, ind] = matlab.internal.graph.MLGraph.edgesConstrWithIndex(s, t, totalNodes);
Error in graph (line 300)
matlab.internal.graph.constructFromEdgeList(...
Error in bisection3 (line 30)
graph(x,y1,y2);
If this has to do with x,y1,y2 being consisted by only positive integers, that does not make sense to me, since plots should also be consisted of negative coordinances if necessary. I am new in matlab so excuse me if this a simple question. I tried to apply other solutions but they din not work
Thank you in advance

 Réponse acceptée

The identifier graph already has a meaning in MATLAB. If possible I recommend naming your function and your function file something else.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by