Gradient function not working

4 views (last 30 days)
Chris Brown
Chris Brown on 6 Jan 2017
Commented: Chris Brown on 6 Jan 2017
I have a 3D grid of data values (F). I modify a series of points (in a 1D strip). When I take the gradient of the function F , the gradient only takes the central difference in one direction. I am unsure why it does not take the difference in 3D?
Here is a simplified version of my code. Any help would be greatly appreciated.
Thanks
%%gradienttest
%test whether gradient works elsewhere
%variables
K = 2.87; %Thermal conductivity (W/ m K)
%general
sT = 10; %surface temperature ('C)
Tg = 2; %Temperature gradient ('C / 100 m)
Ini = 1; %initial conditons
nt = 100; %number of time steps
x = 0:100;
y = 0:100;
z = 0:60;
%%Mesh / grid
[X,Y,Z] = meshgrid(x,y,z);
%%Tnitial temperature model
F = sT + ( (Tg.*K.*Z)./K);Z=Y;
x = 101;
y = 101;
z = 61;
for a=1:Ini %Change in temperature of elements
i=x-45;
j=y-45;
%k=z-25;
k=34:z-22;
F(j,i,k)=30;
end
Tg=gradient(F,100,100,100);

Accepted Answer

Stephen23
Stephen23 on 6 Jan 2017
Edited: Stephen23 on 6 Jan 2017
According to the gradient documentation:
[Tx,Ty,Tz] = gradient(...)

More Answers (0)

Categories

Find more on Oil, Gas & Petrochemical 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!