필터 지우기
필터 지우기

How to plot a surface curve with inequalities?

조회 수: 7 (최근 30일)
Aditya Zade
Aditya Zade 2023년 5월 30일
댓글: Aditya Zade 2023년 5월 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
Sulaymon Eshkabilov 2023년 5월 30일
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