Rob,
I think the problem is that on the last line of your code, i.e.,
ff=10*xx^0.5-3*yy^1.2 +2*yy;
you're taking the matrix square root of xx and not of each matrix element individually. What you probably want to do is the following:
ff=10*xx.^0.5-3*yy.^1.2 +2*yy;
( Notice the point in xx.^0.5. This is an elementwise operation, it basically will take the square root of each individual element, rather than from the entire matrix).
I wrote a little example to explain the difference between elementwise and full matrix operations:
A = rand(2,2)
A^2
A*A
A.^2
B = A^0.5
B*B
The warning you get, relates to the matrix xx, which is close to singular. Remember that a matrix is singular iff it has a zero eigenvalue. The fact that xx is close to singular can be observed by having a look at its eigen values:
lambda = eig(xx);
disp(sprintf('The last and smallest eigenvalue is %d', lambda(end)))
You can observe the last (and smallest) eigenvalue is 1.6421e-142. This last eigenvalue is so small, that it renders the square root calculation of xx inaccurate.
Best Answer