Input argument "xval" is undefined. Error in ==> vectorfield at 5 m=length(xval);

2 views (last 30 days)
Hello, I am trying to run this program, but I've got this error message. Could you help me please to solve this problem? The script file is
function vectorfield(deqns,xval,yval,zval)
t = 0;
m=length(xval);
n=length(yval);
o=length(zval);
xxval = [];
yyval = [];
zzval = [];
x1=[];
y1=[];
z1=[];
for a=1:m
for b=1:n
for c = 1:o
pts=feval(deqns,t,[xval(a);yval(b);zval(c)]);
x1=[x1;pts(1)];
y1=[y1;pts(2)];
z1=[z1;pts(3)];
xxval = [xxval; xval(a)];
yyval = [yyval; yval(b)];
zzval = [zzval; zval(c)];
end
end
end
arrow=sqrt(x1.^2+y1.^2+z1.^2);
u = x1./ar if truerow;
v = x1./arrow;
w = x1./arrow;
quiver3(xxval,yyval,zzval,u,v,w);
axis tight;
Thanks

Answers (1)

Jan
Jan on 16 Sep 2013
"xval" is undefined, if you did not provide it as input. You have to call this function in a way like:
vectorfield(@Equation, 1, 2, 3)
Due to the absence of a documentation in this function, I cannot guess how the inputs should look like exactly.
Please post a complete copy of the error message inside the text of the question. In this case, as in almost all others also, the complete message contains exactly the information I gave, but in a less specific formulation.

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!