Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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 Commenti
Dyuman Joshi
Dyuman Joshi il 13 Ott 2023
Modificato: Dyuman Joshi il 13 Ott 2023
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?

Accedi per commentare.

Risposta accettata

Star Strider
Star Strider il 13 Ott 2023
Modificato: Star Strider il 13 Ott 2023
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)
.

Più risposte (1)

Dyuman Joshi
Dyuman Joshi il 13 Ott 2023
Modificato: Dyuman Joshi il 13 Ott 2023
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.

Categorie

Scopri di più su Graphics Object Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by