Partial Derivatives function numerical computing

4 次查看(过去 30 天)
So I have the following problem:
There is an equation for B(x,y,z), which I have calculated.
Let's say it's B = [3x.^2 - y.^2 5zy 3xz]
I have taken the partial derivatives as follows using the diff function (as everything is symbolic) and have calculated analytically the partial derivatives.
Gxx = diff(Bx, x)
Gxy = diff(Bx, y)
Gxz = diff(Bx, z)
etc.
What I want to do is create a separate function that will take in (x,y,z) values and spit out the numerical computing of Gxx, Gxy (since the partial derivative analytically has already been calculated).
I have been able to numerically compute using vpa and sub, but I have to put the x,y,z values into the sub function...I wanted something like:
function G = computerDerivatives(x,y,z) that will taken in x,y,z and give me the numerical computing of Gxx, Gxy.
If someone can provide guidance, that will be much appreciated.

采纳的回答

David Hill
David Hill 2020-9-3
function [Gx,Gy,Gz] = computerDerivatives(c,Gxx,Gxy,Gxz)
x=c(1);
y=c(2);
z=c(3);
Gx=subs(Gxx);
Gy=subs(Gxy);
Gz=subs(Gxz);
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by