필터 지우기
필터 지우기

How to mark points at 1-5 on the x-axis in the plot

조회 수: 2 (최근 30일)
Aijalon Marsh
Aijalon Marsh 2023년 10월 13일
편집: Star Strider 2023년 10월 13일
clc;
clear all ;
Ld=(0:0.00005:0.005);
w=0.001;
L=0.007;
P=4*0.001;
Ta=25;
h=375;
Kf=175;
Kd=0.032;
Tb=75;
Ap=3.02*10^-3;
N=238;
Ac=10^-6;
m=92.6;
Lf=L-Ld;
Rtf=(cosh(m.*Lf)+(h./(m.*Kf)).*sinh(m.*Lf))./(sqrt(4*h.*(w)^3*Kf).*(sinh(m.*Lf)+h./(m.*Kf)).*cosh(m.*Lf));
R_fins=Rtf/N;
Rf_cond=Ld/(Kf*N*Ac);
Rd_cond=Ld/(Kd*(Ap-N*Ac));
Ad=Ld./(Kd*Rd_cond);
R_conv=1./(h*Ad);
q=(Tb-Ta)./(Rd_cond+R_conv)+(Tb-Ta)./(Rf_cond+R_fins);
Q=min(q);
figure
plot(Ld, q);
xlabel('Dust layer thickness, Ld (m)');
ylabel('Heat Rate, q(W)');
grid on;
fprintf("Total heat rate %.2f°C\n", Q);
  댓글 수: 2
Dyuman Joshi
Dyuman Joshi 2023년 10월 13일
편집: Dyuman Joshi 2023년 10월 13일
What do you mean by "mark points at 1-5 on the x-axis in the plot"?
Could you give an example of what the expected output is?
Aijalon Marsh
Aijalon Marsh 2023년 10월 13일
should look like that.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2023년 10월 13일
편집: Star Strider 2023년 10월 13일
One possibility —
clc;
clear all ;
Ld=(0:0.00005:0.005);
w=0.001;
L=0.007;
P=4*0.001;
Ta=25;
h=375;
Kf=175;
Kd=0.032;
Tb=75;
Ap=3.02*10^-3;
N=238;
Ac=10^-6;
m=92.6;
Lf=L-Ld;
Rtf=(cosh(m.*Lf)+(h./(m.*Kf)).*sinh(m.*Lf))./(sqrt(4*h.*(w)^3*Kf).*(sinh(m.*Lf)+h./(m.*Kf)).*cosh(m.*Lf));
R_fins=Rtf/N;
Rf_cond=Ld/(Kf*N*Ac);
Rd_cond=Ld/(Kd*(Ap-N*Ac));
Ad=Ld./(Kd*Rd_cond);
R_conv=1./(h*Ad);
q=(Tb-Ta)./(Rd_cond+R_conv)+(Tb-Ta)./(Rf_cond+R_fins);
Q=min(q);
figure
plot(Ld, q);
xlabel('Dust layer thickness, Ld (m)');
ylabel('Heat Rate, q(W)');
grid on;
fprintf("Total heat rate %.2f°C\n", Q);
Total heat rate 37.54°C
xlim([0 6]*1E-3)
Ldq = get(gca,'XTick');
qv = interp1(Ld, q, Ldq);
idx = isfinite(qv);
text(Ldq(idx), qv(idx), compose('Ld = %.3f\nq = %8.3f\n\\downarrow',[Ldq(idx); qv(idx)]'), 'Horiz','left', 'Vert','bottom', 'FontSize',8)
.

추가 답변 (1개)

Dyuman Joshi
Dyuman Joshi 2023년 10월 13일
편집: Dyuman Joshi 2023년 10월 13일
Okay, you want to create data-tips. Data-tips can be added using datatip -
Ld=(0:0.00005:0.005);
w=0.001;
L=0.007;
P=4*0.001;
Ta=25;
h=375;
Kf=175;
Kd=0.032;
Tb=75;
Ap=3.02*10^-3;
N=238;
Ac=10^-6;
m=92.6;
Lf=L-Ld;
Rtf=(cosh(m.*Lf)+(h./(m.*Kf)).*sinh(m.*Lf))./(sqrt(4*h.*(w)^3*Kf).*(sinh(m.*Lf)+h./(m.*Kf)).*cosh(m.*Lf));
R_fins=Rtf/N;
Rf_cond=Ld/(Kf*N*Ac);
Rd_cond=Ld/(Kd*(Ap-N*Ac));
Ad=Ld./(Kd*Rd_cond);
R_conv=1./(h*Ad);
q=(Tb-Ta)./(Rd_cond+R_conv)+(Tb-Ta)./(Rf_cond+R_fins);
Q=min(q);
figure
p = plot(Ld, q);
xlabel('Dust layer thickness, Ld (m)');
ylabel('Heat Rate, q(W)');
grid on;
fprintf("Total heat rate %.2f°C\n", Q);
Since only 1 data-tip can be added at a time, use a for loop -
%Define the x values to get data-tips for
vec = (1:5)/1e3;
for k=vec
%% Using tolerance to compare floating point numbers
%The highest significant digit of values in Ld is 5, corresponding to
%10^-5 or 1e-5, thus select a tolerance smaller than that
idx = abs(Ld-k)<1e-6;
datatip(p, Ld(idx), q(idx))
end
As the graph is monotonic, there is only 1 y-point corresponding to a single x-point. Thus we can directly use logical-indexing.
For other cases, the code might need modifications.

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by