h = double(subs(hf,{x,y},{x(1),x(2)})); in matlab

Assuming hf is a symbolic expression in terms of x and y, you can use the subs() function to substitute the values of x(1) and x(2) in hf. Then, use the double() function to convert the result to a numeric value. The code would look like:

main.m
h = double(subs(hf, {x,y}, {x(1),x(2)}));
42 chars
2 lines

Here, {x,y} and {x(1),x(2)} are the from-values and to-values, respectively, for the subs() function.

Please note that hf needs to be a symbolic expression or a variable with symbolic value in order for this to work.

related categories

gistlibby LogSnag