필터 지우기
필터 지우기

Finding the gradient of the function

조회 수: 1 (최근 30일)
Amy Topaz
Amy Topaz 2022년 4월 14일
댓글: DGM 2022년 4월 17일
I need to find the gradient (differentiation) of the below function k1 wrt a11 for the values of z1 and plot with respect a11.
z1 = [0.00008 0.009]';
a11 = -2:0.002:2;
k1 = atan(((0.02 + a11)./z1)) + atan((0.03 - a11)./z1);
  댓글 수: 1
DGM
DGM 2022년 4월 17일
Edited to restore deleted question.

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

채택된 답변

Star Strider
Star Strider 2022년 4월 14일
Symbolically —
syms a11 z1
sympref('AbbreviateOutput',false);
k1 = atan(((0.02 + a11)./z1)) + atan((0.03 - a11)./z1)
k1 = 
grad_k1 = gradient(k1)
grad_k1 = 
grad_k1_fcn = matlabFunction(grad_k1)
grad_k1_fcn = function_handle with value:
@(a11,z1)[1.0./(z1.*(1.0./z1.^2.*(a11+1.0./5.0e+1).^2+1.0))-1.0./(z1.*(1.0./z1.^2.*(a11-3.0./1.0e+2).^2+1.0));-(1.0./z1.^2.*(a11+1.0./5.0e+1))./(1.0./z1.^2.*(a11+1.0./5.0e+1).^2+1.0)+(1.0./z1.^2.*(a11-3.0./1.0e+2))./(1.0./z1.^2.*(a11-3.0./1.0e+2).^2+1.0)]
.
  댓글 수: 2
Amy Topaz
Amy Topaz 2022년 4월 14일
Could you plot and show me the plot please
Star Strider
Star Strider 2022년 4월 14일
편집: Star Strider 2022년 4월 14일
Sure!
syms a11 z1
sympref('AbbreviateOutput',false);
k1 = atan(((0.02 + a11)./z1)) + atan((0.03 - a11)./z1)
k1 = 
grad_k1 = gradient(k1)
grad_k1 = 
grad_k1_fcn = matlabFunction(grad_k1)
grad_k1_fcn = function_handle with value:
@(a11,z1)[1.0./(z1.*(1.0./z1.^2.*(a11+1.0./5.0e+1).^2+1.0))-1.0./(z1.*(1.0./z1.^2.*(a11-3.0./1.0e+2).^2+1.0));-(1.0./z1.^2.*(a11+1.0./5.0e+1))./(1.0./z1.^2.*(a11+1.0./5.0e+1).^2+1.0)+(1.0./z1.^2.*(a11-3.0./1.0e+2))./(1.0./z1.^2.*(a11-3.0./1.0e+2).^2+1.0)]
figure
hfs = fsurf(grad_k1, [-1 1 -1 1]*4, 'MeshDensity',75);
hfs(1).EdgeColor = 'interp'; % Optional
hfs(2).EdgeColor = 'interp'; % Optional
EDIT — (14 Apr 2022 at 13:22)
Changed (increased) 'MeshDensity'.
.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by