substitution of values in a symbolic function with multiple variables

9 views (last 30 days)
Hi there,
I have a function f(x,y,z) that I have to derive with respect to x, evaluate in a point p(x1,x2,x3) and then elevate that number to the power of two, and I'd like to do it all in a matlab function.
So I used the symbolic function syms and defined all my variables and derived the funcion with "diff";
Now, how can I evaluate the function I have in the point p?
Thanks a lot,
Margherita

Answers (1)

madhan ravi
madhan ravi on 30 Nov 2018
Edited: madhan ravi on 30 Nov 2018
EDITED
See subs() for more examples
syms x y z %an example
f=x.^+y.^2+z.^2;
x1=1:10;
x2=11:20;
x3=21:30;
vpa(subs(f,{x,y,z},{x1,x2,x3}),4) %use subs() to substitute the points
command window:
ans =
[ 442.0, 1.678e7, 2.542e12, 7.206e16, 9.313e20, 7.959e24, 5.412e28, 3.245e32, 1.825e36, 1.0e40]
>>

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!