Gradient of a surface

10 ビュー (過去 30 日間)
Konstantinos Tsitsilonis
Konstantinos Tsitsilonis 2018 年 1 月 3 日
回答済み: Walter Roberson 2018 年 1 月 3 日
Hi all,
I have written the following code in order to determine the gradient of a function between certain X and Y values specified by the X and Y values limits of the graph I am plotting.
K = 273.15 ; %constant
[x, y] = meshgrid(1.4:0.1:5,70:5:200) ; %x & y values
z = (x.^(0.4/1.4) - 1) ./ ( (y + K)/(25 + K) - 1) ; %function
[Fx, Fy] = gradient(z) ; %gradient of the function
figure
contour(x, y, z, [0:0.1:1], 'ShowText', 'on')
ax = gca ;
ax.XLim = [1.4, 5] ;
ax.YLim = [70, 200] ;
grid on
xlabel('Pressure Ratio (-)')
ylabel('Temperature (degC)')
Howver, when I try to plot the Fx and Fy, the plot comes out to be blank. Therefore, how do i find the gradient of the function between the desired X & Y values?
Thanks for your help in advance,
KMT.

採用された回答

Walter Roberson
Walter Roberson 2018 年 1 月 3 日
>> max(Fx(:))
ans =
0.145210103674753
>> min(Fx(:))
ans =
0.0155307058204656
>> max(Fy(:))
ans =
-0.00505640320134679
>> min(Fy(:))
ans =
-0.386812925230569
The gradient is the change in values. It is to be expected that the change in values is often less than the range of values that you happen to be plotting. If you stick with the contour interval 0:.1:1 then only the 0.1 level has any data for Fx, and none of the Fy is in the range 0 to 1 so if you use 0:0.1:1 then as your level list then you would expect a blank plot.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVector Fields についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by