How to plot a surface curve with inequalities?

7 次查看(过去 30 天)
M = 0.85 : 1/200 : 1 ;
Psi = 0 : 1/200 : 30 ;
dp = 0.6 : 1/200 : 1 ;
[ X, Y, Z ] = meshgrid( dp, Psi, M ) ;
ineq = ( X > 1 - ( 4 * Y / 360 ) ) & ( X > (2/pi)*asin(Z/2) ) & ( X < (2/pi)*asin(Z) ) ;

采纳的回答

Sulaymon Eshkabilov
Note that 1st of all, in order to compare X vs. Y vs. Z, their size "MUST" match. Therefore, to make their size compatible, e.g. 200.
Here is one of the possible solutions of this exercise:
N = 200;
M = linspace(0.85 ,1, N) ;
Psi = linspace(0,30, N) ;
dp = linspace(0.6,1, N) ;
[ X, Y] = meshgrid(dp, Psi) ;
[~, ZZ] = meshgrid(M, M);
IND = ( X > 1 - ( 4 * Y / 360 )) & ( X > (2/pi)*asin(ZZ/2) ) & ( X < (2/pi)*asin(ZZ)) ;
Xs = X.*(IND);
Ys = Y.*(IND);
Zs = ZZ.*(IND);
meshc(Xs, Ys, Zs)
xlabel('dp')
ylabel('psi')
zlabel('M')
Check your specified inequality conditions whether they are correct or not.
  1 个评论
Aditya Zade
Aditya Zade 2023-5-30
Thanks for the answer. But it seems the shape of the plot is wrong. The inequalities are correct in your script. For your reference, the plot drawn by John is correct. The plot should only be valid between M = 0.87 to 1.

请先登录,再进行评论。

更多回答(1 个)

John D'Errico
John D'Errico 2023-5-30
编辑:John D'Errico 2023-5-30
And exactly what is the problem? I think what you do not understand is, what you have created is NOT a surface.
M = 0.85 : 1/200 : 1 ;
Psi = 0 : 1/200 : 30 ;
dp = 0.6 : 1/200 : 1 ;
[ X, Y, Z ] = meshgrid( dp, Psi, M ) ;
ineq = ( X > 1 - ( 4 * Y / 360 ) ) & ( X > (2/pi)*asin(Z/2) ) & ( X < (2/pi)*asin(Z) );
X(~ineq) = NaN;
Y(~ineq) = NaN;
Z(~ineq) = NaN;
plot3(X(:),Y(:),Z(:),'.')
The result is a set of points that live in a triangular region in X and Y, with one curved surface, where Z is a function of X and Y.
But there is no "surface" that you have created. You might think of what you have done is to create a volume, the set of points delineated by those constraints.
  1 个评论
Aditya Zade
Aditya Zade 2023-5-30
编辑:Aditya Zade 2023-5-30
Hi John,
The problem here is its hard to understand the shape of the 3d set of points. Is there a way to have boundaries or change of color of the set of points as the value of M (Z axis) increases? Something similar to what we have in a surface plot.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by