I had a function which was working perfectly for a while, however suddenly stopped working. The function is to plot a 2D vector field with inputs of the components in the x-direction (i) and y-direction (j) as well as mins and maxes.
function [ output ] = VecField(i,j,min,max)
[x,y] = meshgrid(min:20:max);
quiver(x,y,i,j,'color','red','linewidth',1.2)
if min > 0
min_axes = 0.95*min;
else
min_axes = 1.05*min;
end
if max > 0
max_axes = 1.05*max;
else
max_axes = 0.95*max;
end
axis([min_axes max_axes min_axes max_axes])
title('Velocity vector field plot of over cylinder (inviscid)')
xlabel('x-axis')
ylabel('y-axis')
end
An example input which was previously working is: VecField(((-x-y)./((x.^2+y.^2).^0.5)),((x-y)./((x.^2+y.^2).^0.5)),-200,200)
While I can understand the error (Undefined function or variable 'x'.), I am unsure how to remedy it. If I enclose the functions in quotation marks, then the quiver function can no longer handle the inputs.
Are there any simple ways of getting around this?