How to plot a surface curve with inequalities?

7 views (last 30 days)
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) ) ;

Accepted Answer

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 30 May 2023
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 Comment
Aditya Zade
Aditya Zade on 30 May 2023
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.

Sign in to comment.

More Answers (1)

John D'Errico
John D'Errico on 30 May 2023
Edited: John D'Errico on 30 May 2023
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 Comment
Aditya Zade
Aditya Zade on 30 May 2023
Edited: Aditya Zade on 30 May 2023
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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!