Extend only two lines on a plot
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jolie Gaffron
le 27 Sep 2024
Commenté : Star Strider
le 27 Sep 2024
I made a plot on Matlab with three experimental data lines and two theoretical. I need to extend only the two theoretical (Vturb and Vlam) to the top of the plot. Everything I've tried has not worked so any ideas would be much appreciated.
%140%
DP140= [0.200 0.192 0.182 0.170 0.162 0.151 0.138 0.132 0.130 0.122 0.117 0.108 0.102 0.087 0.076];
DPlb140=DP140*5.20;
V140=((2*DPlb140)/0.00238).^(1/2);
VCL140 = V140/29.5626;
%60 Hz%
DP60 = [0.043 0.045 0.042 0.040 0.038 0.037 0.035 0.032 0.031 0.031 0.027 0.026 0.024 0.021 0.018];
DPlb60=DP60*5.20;
V60=((2*DPlb60)/0.00238).^(1/2);
VCL60 = V60/13.7076;
%100 Hz%
DP100 = [0.123 0.118 0.112 0.108 0.103 0.095 0.089 0.085 0.081 0.078 0.075 0.065 0.062 0.057 0.042];
DPlb100=DP100*5.20;
V100=((2*DPlb100)/0.00238).^(1/2);
r = [0 2 4 6 8 10 12 14 16 18 20 22 24 26 28]/304.8;
R = 0.125;
rR = r/R;
VCL100 = V100/23.1836;
Vlam = (1-rR.^2);
Vturb = (1-rR).^(1/7);
plot(VCL140, rR)
hold on
plot(VCL60, rR)
plot(VCL100, rR)
plot(Vturb,rR)
plot(Vlam,rR)
ylabel("r/R")
xlabel("V/Vcl")
title("Velocites vs. Distance")
legend("Meas V140","Meas V60","Meas V100", "Laminar", "Turbulent")
hold off
0 commentaires
Réponse acceptée
Star Strider
le 27 Sep 2024
One option is to extrapolate the two curves.
That then changes these lines:
plot(Vturb,rR)
plot(Vlam,rR)
to these modified lines:
yl = ylim;
Vte = interp1(rR, Vturb, yl(2), 'pchip', 'extrap');
Vle = interp1(rR, Vlam, yl(2), 'pchip', 'extrap');
plot([Vturb Vte],[rR yl(2)])
plot([Vlam Vle],[rR yl(2)])
with this result —
%140%
DP140= [0.200 0.192 0.182 0.170 0.162 0.151 0.138 0.132 0.130 0.122 0.117 0.108 0.102 0.087 0.076];
DPlb140=DP140*5.20;
V140=((2*DPlb140)/0.00238).^(1/2);
VCL140 = V140/29.5626;
%60 Hz%
DP60 = [0.043 0.045 0.042 0.040 0.038 0.037 0.035 0.032 0.031 0.031 0.027 0.026 0.024 0.021 0.018];
DPlb60=DP60*5.20;
V60=((2*DPlb60)/0.00238).^(1/2);
VCL60 = V60/13.7076;
%100 Hz%
DP100 = [0.123 0.118 0.112 0.108 0.103 0.095 0.089 0.085 0.081 0.078 0.075 0.065 0.062 0.057 0.042];
DPlb100=DP100*5.20;
V100=((2*DPlb100)/0.00238).^(1/2);
r = [0 2 4 6 8 10 12 14 16 18 20 22 24 26 28]/304.8;
R = 0.125;
rR = r/R;
VCL100 = V100/23.1836;
Vlam = (1-rR.^2);
Vturb = (1-rR).^(1/7);
figure
plot(VCL140, rR)
hold on
plot(VCL60, rR)
plot(VCL100, rR)
yl = ylim;
Vte = interp1(rR, Vturb, yl(2), 'pchip', 'extrap');
Vle = interp1(rR, Vlam, yl(2), 'pchip', 'extrap');
plot([Vturb Vte],[rR yl(2)])
plot([Vlam Vle],[rR yl(2)])
ylabel("r/R")
xlabel("V/Vcl")
title("Velocites vs. Distance")
legend("Meas V140","Meas V60","Meas V100", "Laminar", "Turbulent")
hold off
The other option is to set:
ylim([min(ylim) max(rR)]
That re-positions the upper value of ylim to the highest value of ‘rR’.
It all depends on what you want to do.
.
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Legend 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!