Horizontal line up to graph line
Afficher commentaires plus anciens
Hi everyone,
I want to put horizontal line to my graph . The line extend up to end of the graph however it should be cut at point to graph line and horizontal line intersect. Also I want to change chracter to subscript 1 in S1 . How I do it? Thanks.

clear
clc
y = [0.5 1 2 3.5 6 8 10.2 14 18 21 35 41 58 60.5 66 70 90 100];
y1 = [0 0.5 1 2 3.5 6 8 10.2 14 18 21 35 37.32]; % Trapezoidal integralin tanım aralığı (y1)
u = [0.271 0.518 1.113 1.93 3.137 4.157 5.32 7.28 9.22 10.79 11.3 11.52 11.55 11.51 11.58 11.6 11.59 11.50];
u1 = [0 0.271 0.518 1.113 1.93 3.137 4.157 5.32 7.28 9.22 10.79 11.3 11.385] % Trapezoidal integralin tanım aralığı (u1)
U = u(end); % Free stream velocity
u99=0.99.*U;
L=interp1(u(1:13),y(1:13),u99); % Sınır tabakası
S1 = trapz(y1,1-u1/U); % Integral of (1-u/U) w.r.t. y
S2 = trapz(y1,(u1/U).*(1-u1/U)); % Integral of (u/U)*(1-u/U) w.r.t. y
S3 = trapz(y1,(u1/U).*(1-(u1.*u1)/(U.*U))); % Integral of (u/U)*(1-(u/U)^2) w.r.t. y
fprintf('\nU = %6.2f (mm)\ndelta1 = %6.2f (mm)\ndelta2 = %6.2f (mm) \ndelta3 = %6.2f (mm)\n',...
U,S1,S2,S3);
plot(u,y,'p-','LineWidth',1,'Marker','square'); xlabel('u (m/s)'); ylabel('y (mm)');
hold on
plot([0 U],S1*[1 1],'r--','color',[0 0 1]); % yatay cizgi y = S1
theText = sprintf('\\delta1 = %4.3f',S1);
text(0.05*U,1.2*S1,theText,'FontSize',12); % yazı karakteristikleri
Réponse acceptée
Plus de réponses (1)
y = [0.5 1 2 3.5 6 8 10.2 14 18 21 35 41 58 60.5 66 70 90 100];
y1 = [0 0.5 1 2 3.5 6 8 10.2 14 18 21 35 37.32]; % Trapezoidal integralin tanım aralığı (y1)
u = [0.271 0.518 1.113 1.93 3.137 4.157 5.32 7.28 9.22 10.79 11.3 11.52 11.55 11.51 11.58 11.6 11.59 11.50];
u1 = [0 0.271 0.518 1.113 1.93 3.137 4.157 5.32 7.28 9.22 10.79 11.3 11.385] % Trapezoidal integralin tanım aralığı (u1)
U = u(end); % Free stream velocity
u99=0.99.*U;
L=interp1(u(1:13),y(1:13),u99); % Sınır tabakası
S1 = trapz(y1,1-u1/U); % Integral of (1-u/U) w.r.t. y
S2 = trapz(y1,(u1/U).*(1-u1/U)); % Integral of (u/U)*(1-u/U) w.r.t. y
S3 = trapz(y1,(u1/U).*(1-(u1.*u1)/(U.*U))); % Integral of (u/U)*(1-(u/U)^2) w.r.t. y
fprintf('\nU = %6.2f (mm)\ndelta1 = %6.2f (mm)\ndelta2 = %6.2f (mm) \ndelta3 = %6.2f (mm)\n',...
U,S1,S2,S3);
plot(u,y,'p-','LineWidth',1,'Marker','square'); xlabel('u (m/s)'); ylabel('y (mm)');
hold on
% plot([0 U],S1*[1 1],'r--','color',[0 0 1]); % yatay cizgi y = S1
yline(S1, 'b--'); % horizontal line
theText = sprintf('\\delta_1 = %4.3f',S1); % use _ for subscript
text(0.05*U,1.2*S1,theText,'FontSize',12); % yazı karakteristikleri
1 commentaire
jack london
le 12 Déc 2021
Modifié(e) : jack london
le 12 Déc 2021
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

