How to plot a surface curve with inequalities?
1 次查看(过去 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) ) ;
0 个评论
采纳的回答
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 个)
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!