how to modify a plot
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Alina Abdikadyr
le 17 Fév 2023
Commenté : Star Strider
le 19 Fév 2023
Hello, please could you help me with a code?
So I plotted a graph, and I need to continue my orange and yellow line until the green line and shade the region?
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
figure(5); plot(V,n1v)
hold on
plot(V,nmaxx)
hold on
plot(V,nminn)
hold on
plot(V2,n2v);
plot(Vmax,nv);
xlim([-1 400]);
ylim([-5 5]);
0 commentaires
Réponse acceptée
Star Strider
le 17 Fév 2023
Extending the lines is straightforward.
What region do you want to shade? I created patch objects for all of them, so choose the ones you want. You can turn off the edges of the patch objects wiby adding 'EdgeColor','none' to their arguments.
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
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');
xlim([-1 400]);
ylim([-5 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)], 'c', 'FaceAlpha',0.25)
patch([V2 flip(V2)], [ones(size(n2v))*min(n2v) flip(n2v)], 'g', 'FaceAlpha',0.25)
patch([V flip(V)], [n1v ones(size(n1v))*max(n1v)], [0.8 0.4 0.2], 'FaceAlpha',0.25)
The patch pbjects were a bit of a challenge because the vectors creating them were not as I expected them to be. You can identify them by their colours.
.
2 commentaires
Plus de réponses (1)
Sulaymon Eshkabilov
le 17 Fév 2023
Modifié(e) : Sulaymon Eshkabilov
le 17 Fév 2023
This is how it can be attained:
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
%%
figure(5);
plot(V,n1v, 'r-')
hold on
V1 = [V, Vmax(1)];
Nm1 = [nmaxx, nmaxx(1)];
plot(V1,Nm1, 'b-')
hold on
V1 = [V, Vmax(1)];
Nm2 = [nminn, nminn(end)];
plot(V1,Nm2, 'k-')
hold on
plot(V2,n2v, 'm-');
plot(Vmax,nv, 'g-', 'linewidth', 2);
xlim([-1 400]);
ylim([-5 5]);
0 commentaires
Voir également
Catégories
En savoir plus sur Line Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!