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

4 ビュー (過去 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 Center および File ExchangeGraphics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by