fill in the area in plot

1 次查看(过去 30 天)
How can I fill in the area
My code is
%3.2
clear all
W=45000;
S=9;
b=7.5;
clmax=2;
clmin=-1;
nmax=4;
AR=7;
nmin=-3;
clalpha = 2*pi;
Vdive=290;
Vstall=sqrt(2*W/(1.225*S*clmax));
cd0 = 0.005;
k = 1/pi/AR;
n1v = 0:0.25:4;
i=0;
for n1 = 0:0.25:4
i=i+1;
V(i) = sqrt(2*n1*W/1.225/S/clmax);
nmaxx(i)=nmax;
nminn(i)=nmin;
end
j=0;
n2v = -3:0.25:0;
for n2 = -3:0.25:0
j=j+1;
V2(j) = sqrt(2*n2*W/1.225/S/clmin);
nmaxx(j)=nmax;
nminn(j)=nmin;
end
k=0;
nv=-3:0.25:4;
for n=-3:0.25:4
k=k+1;
Vmax(k)=Vdive;
end
m=0;
n3v=-3:0.25:4;
for n3=-3:0.25:4
m=m+1;
Vstall1(m)=Vstall;
end
figure(5); plot(V,n1v, 'DisplayName','n1v')
hold on
plot([V Vmax(end)],[nmaxx nmaxx(end)], 'DisplayName','nmaxx')
hold on
plot([V Vmax(end)],[nminn nminn(end)], 'DisplayName','nminn')
hold on
plot(V2,n2v, 'DisplayName','n2v');
plot(Vmax,nv, 'DisplayName','nv');
hold on
plot(Vstall1,n3v, 'DisplayName','n3v');
xlim([-1 325]);
ylim([-4 5]);

采纳的回答

Star Strider
Star Strider 2023-2-19
Please see my Comment to your previous post.
I do not know what parts you want to fill, so again, I filled each of them.
Choose the appropriate patch calls —
%3.2
clear all
W=45000;
S=9;
b=7.5;
clmax=2;
clmin=-1;
nmax=4;
AR=7;
nmin=-3;
clalpha = 2*pi;
Vdive=290;
Vstall=sqrt(2*W/(1.225*S*clmax));
cd0 = 0.005;
k = 1/pi/AR;
n1v = 0:0.25:4;
i=0;
for n1 = 0:0.25:4
i=i+1;
V(i) = sqrt(2*n1*W/1.225/S/clmax);
nmaxx(i)=nmax;
nminn(i)=nmin;
end
j=0;
n2v = -3:0.25:0;
for n2 = -3:0.25:0
j=j+1;
V2(j) = sqrt(2*n2*W/1.225/S/clmin);
nmaxx(j)=nmax;
nminn(j)=nmin;
end
k=0;
nv=-3:0.25:4;
for n=-3:0.25:4
k=k+1;
Vmax(k)=Vdive;
end
m=0;
n3v=-3:0.25:4;
for n3=-3:0.25:4
m=m+1;
Vstall1(m)=Vstall;
end
figure(5); plot(V,n1v, 'DisplayName','n1v')
hold on
plot([V Vmax(end)],[nmaxx nmaxx(end)], 'DisplayName','nmaxx')
hold on
plot([V Vmax(end)],[nminn nminn(end)], 'DisplayName','nminn')
hold on
plot(V2,n2v, 'DisplayName','n2v');
plot(Vmax,nv, 'DisplayName','nv');
hold on
plot(Vstall1,n3v, 'DisplayName','n3v');
xlim([-1 325]);
ylim([-4 5]);
patch([Vmax(end) V2 flip(V2) Vmax(end)], [zeros(size([n2v n2v(1)])) flip(n2v) n2v(1)], 'm', 'FaceAlpha',0.25)
patch([V Vmax(end) Vmax(end) flip(V)], [zeros(size([n1v n1v(end)])) n1v(end) flip(n1v)], 'm', 'FaceAlpha',0.25)
LvVs1 = V<=Vstall; % Logical Vector: Region 4
LvVs2 = V>=Vstall; % Logical Vector: Region 1
LvV2s1 = V2<=Vstall; % Logical Vector: Region 3
LvV2s2 = V2>=Vstall; % Logical Vector: Region 2
patch([V2(LvV2s1) flip(V2(LvV2s1))], [ones(size(n2v(LvV2s1)))*min(n2v) flip(n2v(LvV2s1))], [0.1 0.8 0.3], 'FaceAlpha',0.25) % Region 4
patch([V(LvVs1) flip(V(LvVs1))], [n1v(LvVs1) ones(size(n1v(LvVs1)))*max(n1v)], [0.5 0.2 0.5], 'FaceAlpha',0.25) % Region 1
patch([V2(LvV2s2) flip(V2(LvV2s2))], [ones(size(n2v(LvV2s2)))*min(n2v) flip(n2v(LvV2s2))], [0.3 0.5 0.8], 'FaceAlpha',0.25) % Region 3
patch([V(LvVs2) flip(V(LvVs2))], [n1v(LvVs2) ones(size(n1v(LvVs2)))*max(n1v)], [0.8 0.4 0.2], 'FaceAlpha',0.25) % Region 2
text([25 75 75 25], [3 3 -2 -2], compose('%d',1:4))
I keyed the patch calls and the logical vectors to the appropriate regions in the in-line comments for each of them. Choose the ones you want to fill, and change the colours as necessary.
.

更多回答(2 个)

Sulaymon Eshkabilov

Image Analyst
Image Analyst 2023-2-19

类别

Help CenterFile Exchange 中查找有关 Language Support 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by