Gradient function not working

4 visualizzazioni (ultimi 30 giorni)
Chris Brown
Chris Brown il 6 Gen 2017
Commentato: Chris Brown il 6 Gen 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);

Risposta accettata

Stephen23
Stephen23 il 6 Gen 2017
Modificato: Stephen23 il 6 Gen 2017
According to the gradient documentation:
[Tx,Ty,Tz] = gradient(...)

Più risposte (0)

Categorie

Scopri di più su Oil, Gas & Petrochemical in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by