Horizontal line up to graph line
4 views (last 30 days)
Show older comments
jack london
on 12 Dec 2021
Edited: Walter Roberson
on 12 Dec 2021
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
0 Comments
Accepted Answer
Star Strider
on 12 Dec 2021
Try this —
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);
Ui = interp1(y, u, S1) % 'u' Limit (Intercept) Of Dashed Line
plot(u,y,'p-','LineWidth',1,'Marker','square'); xlabel('u (m/s)'); ylabel('y (mm)');
hold on
plot([0 Ui],S1*[1 1],'r--','color',[0 0 1]); % yatay cizgi y = S1
% plot([0 U],S1*[1 1],'r--','color',[0 0 1]); % yatay cizgi y = S1
theText = sprintf('\\delta_1 = %4.3f',S1); % Convert To Subscript
text(0.05*U,1.2*S1,theText,'FontSize',12, 'Vert','bottom'); % yazı karakteristikleri
The dashed line now only extends to the point of interception with the blue line.
.
0 Comments
More Answers (1)
Chunru
on 12 Dec 2021
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
See Also
Categories
Find more on Line Plots 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!