Basically the original question. I've got a function that shouldnt physically be able to give me complex numbers (the only thing that is taken to a root is a sum of two squares, which has to be positive). I've included the code that I have here. If someone could give me some info on why this is returning complex outputs I would love you forever.
f = @(x1,x2)((1/5)*((x1)^2 + (x2)^2)^(3/2) - (x1^2 + x2^2) + x1/2 + x2/2 + 7);
X1 = linspace(lim(1),lim(2),10);
X2 = linspace(lim(3),lim(4),10);
[x1,x2] = meshgrid(X1,X2);
The only reason I really care is that i'm trying to take this function and put it into the surf function, which threw the error
Error using surf (line 71)
X, Y, Z, and C cannot be complex.
I did a little hunting on my own, and discovered that for some reason, when I put just straight values (like if I were to call f(-4, -3)) it returns a positive decimal number, but when I pass the two matrices, it returns a bunch of complex numbers.