-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExp8_1.m
More file actions
15 lines (15 loc) · 918 Bytes
/
Copy pathExp8_1.m
File metadata and controls
15 lines (15 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
clc; clear; close all;
syms x y z
T = 100 - x^2 - y^2 - z^2;
F = gradient(T, [x y z]);
disp('gradF='); disp(F.');
[X, Y, Z] = meshgrid(-4:2:4); % grid from -4 to 4 with step 2 in each coordinate
Ux = double(subs(F(1), {x, y, z}, {X, Y, Z})); % numeric array for x-component of gradient
Uy = double(subs(F(2), {x, y, z}, {X, Y, Z})); % numeric array for y-component of gradient
Uz = double(subs(F(3), {x, y, z}, {X, Y, Z})); % numeric array for z-component of gradient
quiver3(X, Y, Z, Ux, Uy, Uz, 'LineWidth', 1);
axis equal; grid on; % equal axis scaling and grid
title('Gradient Vector Field T'); % title (shows the gradient symbol)
xlabel('X-axis'); % label x-axis
ylabel('Y-axis'); % label y-axis
zlabel('Z-axis'); % label z-axis