Finding the gradient of the function
2 views (last 30 days)
Show older comments
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);
Accepted Answer
Star Strider
on 14 Apr 2022
Symbolically —
syms a11 z1
sympref('AbbreviateOutput',false);
k1 = atan(((0.02 + a11)./z1)) + atan((0.03 - a11)./z1)
grad_k1 = gradient(k1)
grad_k1_fcn = matlabFunction(grad_k1)
.
2 Comments
Star Strider
on 14 Apr 2022
Edited: Star Strider
on 14 Apr 2022
Sure!
syms a11 z1
sympref('AbbreviateOutput',false);
k1 = atan(((0.02 + a11)./z1)) + atan((0.03 - a11)./z1)
grad_k1 = gradient(k1)
grad_k1_fcn = matlabFunction(grad_k1)
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'.
.
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!