필터 지우기
필터 지우기

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

조회 수: 7 (최근 30일)
Samouil
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
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]

Andrei Bobrov
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)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by