필터 지우기
필터 지우기

Partial Derivatives function numerical computing

조회 수: 2 (최근 30일)
sree chak
sree chak 2020년 9월 3일
답변: David Hill 2020년 9월 3일
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에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by