Horizontal line up to graph line
Show older comments
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
Accepted Answer
More Answers (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 Comment
jack london
on 12 Dec 2021
Edited: jack london
on 12 Dec 2021
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
