/ concept-collection / numbl-surfacefun-intro
Sign in
concept-collection / numbl-surfacefun-intro
numbl-surfacefun-intro / fun_gradient.m
20 lines · 578 BBlameHistoryRaw
1% fun_gradient.m — Surface gradient of a scalar function.
2%
3% grad differentiates a surfacefun, automatically accounting for the
4% on-surface metric. It returns the three Cartesian components of the
5% surface gradient.
7mip load --install flatironinstitute/flatironinstitute/surfacefun
9p = 16;
10nref = 2;
11dom = surfacemesh.sphere(p + 1, nref);
13f = surfacefun(@(x, y, z) cos(6*x) .* y + exp(z), dom);
15[fx, fy, fz] = grad(f);
17figure(1);
18subplot(131), plot(fx), title('\partial_x f')
19subplot(132), plot(fy), title('\partial_y f')
20subplot(133), plot(fz), title('\partial_z f')
moveopenescclose