# How to define the abstract symbolic of 'f=f(x,y,z)' at Matlab-Smbolic.

조회 수: 20(최근 30일)
Samouil 2011년 9월 15일
I have a black-box function of 3-variables : f=f(x,y,z). I would like to define with symbolic the relation of 'f' with 'x','y' and 'z', as the abstract type of mathematics 'f=f(x,y,z)'.
In example, I want to do something like:
syms x y z; _I do not know how to set the symbolic at command line : f=f(x,y,z);
g = x * f + y * f^2 + z; jacobian( g, [x,y,z])
and the expected result will be :
( f + x*(df/dx) + 2*y*f*(df/dx), x*(df/dy) + f^2 + 2*y*f*(df/dy), x*(df/dz) + 2*y*f*(df/dz) + 1)
Thanks.

댓글을 달려면 로그인하십시오.

### 답변(2개)

Lucas García 2011년 9월 15일
You can do the following:
>> syms x y z;
>> f = sym('f(x,y,z)');
>> g = x * f + y * f^2 + z;
>> jacobian(g, [x,y,z])
ans =
[ x*diff(f(x, y, z), x) + 2*y*f(x, y, z)*diff(f(x, y, z), x) + f(x, y, z), 2*y*f(x, y, z)*diff(f(x, y, z), y) + x*diff(f(x, y, z), y) + f(x, y, z)^2, x*diff(f(x, y, z), z) + 2*y*f(x, y, z)*diff(f(x, y, z), z) + 1]
##### 댓글 수: 0표시 이전 댓글 수: -1숨기기 이전 댓글 수: -1

댓글을 달려면 로그인하십시오.

Andrei Bobrov 2011년 9월 15일
syms x y z f
g = x * f + y * f^2 + z
g1 = subs(g,f,'f(x,y,z)')
gj = jacobian(g1,[x y z])
for j1 = [x y z],gj = subs(gj,['diff(f(x, y, z), ', char(j1), ')'],['df',char(j1)]); end
out = subs(gj,'f(x, y, z)',f)

댓글을 달려면 로그인하십시오.

### 범주

Find more on Code Performance in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!