Effacer les filtres
Effacer les filtres

Partial Derivatives function numerical computing

2 vues (au cours des 30 derniers jours)
sree chak
sree chak le 3 Sep 2020
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.

Réponse acceptée

David Hill
David Hill le 3 Sep 2020
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

Plus de réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differential Equations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by