Gradient of a surface

10 Ansichten (letzte 30 Tage)
Konstantinos Tsitsilonis
Konstantinos Tsitsilonis am 3 Jan. 2018
Beantwortet: Walter Roberson am 3 Jan. 2018
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.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 3 Jan. 2018
>> 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.

Weitere Antworten (0)

Kategorien

Mehr zu Vector Fields finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by