I have an existing function of two variables (x,y) called discriminant defined in the following way:
discriminant = xSecondPart * ySecondPart - xySecondPart.^2;
Where xSecondPart and ySecondPart are the second partial derivatives of a function f. xySecondPart is the partial derivative with respect to x of the partial derivative with respect to y of the same function f.
I need to print out the values of discriminant at each value of x in the matrix xAns.
The below code is not working…
for idx = 1:numel(xAns)
disp(discriminant(xAns(idx)));
end
Hopefully someone can provide a solution. Thank you
Best…SL
If you define the function
discriminantanonymously, like so:Then all you have to do is type the following statement in the command line or function you’re running:
If your function has been defined using the elementwise operator ‘.’ wherever necessary, then the statement above will print out the
discriminantfunction evaluated at every element of the matrixxAns, regardless of its size or shape. The values returned will be in the same shape as the matrixxAns. I think that would be the easiest way to solve your problem.