Filling area common to two inequalities?

6 ビュー (過去 30 日間)
SAJAN Phutela
SAJAN Phutela 2023 年 1 月 27 日
コメント済み: SAJAN Phutela 2023 年 1 月 27 日
I am having two inequalities (one is explicit and another in implicit) and I want to fill the area common to these. I have drawn the corresponding equations in matlab but do not know how can I fill the common area. I am also uploading the image in which coloured their common area with help of paint. My code is:
clc;
clear all;
E11=0.041057; E12=-0.117734; E21=0.029952; E22=-0.042564;
A=[1 -E22/E11];
D0=E11*E22-E12*E21
x = linspace(-1, 7); % Row Vector
y1=max(A)*x ;
F=@(x,y) E11.^2*y.^2+E22.^2*x.^2+(2*x.*y.*E11.*E22-4.*x.*y.*D0);
plot(x, y1,'--b','linewidth',1.3)
hold on
fimplicit(F,[0 7 0 20],'--r','linewidth',1.3)
xlim([0,7])
ylim([0,20])
I want to fill the area in which y1>0 and F>0 which is filled with orange color in below image.

回答 (1 件)

KSSV
KSSV 2023 年 1 月 27 日
clc;
clear all;
E11=0.041057;
E12=-0.117734;
E21=0.029952;
E22=-0.042564;
A=[1 -E22/E11];
D0=E11*E22-E12*E21 ;
x1 = linspace(-1, 7); % Row Vector
y1=max(A)*x1 ;
F=@(x,y) E11.^2*y.^2+E22.^2*x.^2+(2*x.*y.*E11.*E22-4.*x.*y.*D0);
[X,Y] = meshgrid(linspace(0,7),linspace(0,20)) ;
F = F(X,Y) ;
[c,h] = contour(X,Y,F,[0 0]) ;
c(:,1) =[] ;
x2 = c(1,:) ;
y2 = c(2,:) ;
plot(x1, y1,'--b','linewidth',1.3)
hold on
plot(x2,y2,'--r','linewidth',1.3)
xlim([0,7])
ylim([0,20])
Now you have the coordinates (x1,y1) and (x2,y2) in hand. You can pick the required coordinates you want and use polyarea
  2 件のコメント
SAJAN Phutela
SAJAN Phutela 2023 年 1 月 27 日
Can u please tell how can I feel the area using polyarea? I have not used earlier, thanks please.
SAJAN Phutela
SAJAN Phutela 2023 年 1 月 27 日
@KSSV thanx for you reply, I also did it but in a different manner, please have alook on it
clc;
clear all;
E11=0.041057;
E12=-0.117734;
E21=0.029952;
E22=-0.042564;
A=[1 -E22/E11];
D0=E11*E22-E12*E21 ;
xmax=5; ymax=20;
F1=@(x,y) E11.^2*y.^2+E22.^2*x.^2+(2*x.*y.*E11.*E22-4.*x.*y.*D0);
F2=@(x,y) y-max(A)*x;
Q1=linspace(0,xmax,500); Q2=linspace(0,ymax,500);
[X,Y] = meshgrid(Q1,Q2) ;
G1 = F1(X,Y) ; %Evaluate the value of functions at grid points
G2= F2(X,Y) ;
[row1,col1] =find(G1>0 & G2>0); % returns the indexing of grid points where conditions are satisfied
row2=col1; col2=row1; % returns the intices of in x and y
X1=Q1(row2); Y1=Q2(col2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
plot(X1,Y1,'.b','MarkerSize',5)
hold on
fimplicit(F1,[0 7 0 20],'-r','linewidth',1.5)
fimplicit(F2,[0 7 0 20],'-g','linewidth',1.5)
xlim([0,xmax])
ylim([0,ymax])

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by