Gradient of a surface
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Konstantinos Tsitsilonis
il 3 Gen 2018
Risposto: Walter Roberson
il 3 Gen 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.
0 Commenti
Risposta accettata
Walter Roberson
il 3 Gen 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.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Vector Fields 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!