Gradient function not working

5 ビュー (過去 30 日間)
Chris Brown
Chris Brown 2017 年 1 月 6 日
コメント済み: Chris Brown 2017 年 1 月 6 日
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);

採用された回答

Stephen23
Stephen23 2017 年 1 月 6 日
編集済み: Stephen23 2017 年 1 月 6 日
According to the gradient documentation:
[Tx,Ty,Tz] = gradient(...)
  1 件のコメント
Chris Brown
Chris Brown 2017 年 1 月 6 日
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by