Gradient function not working
4 次查看(过去 30 天)
显示 更早的评论
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);
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Oil, Gas & Petrochemical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!