Mark a point on graph

1 次查看(过去 30 天)
Hello,
I have made a graph with the following code. My goal was to know whey the y-axis is equal to 0.331. This means, the time it takes for the concentration of the lake to be 0.331. I also wanted to mark that point in my graph. Is that possible?
Thank you in advance
First, let's define our variables:
r = 10^5 ;
V = 10^10 ;
c_i = 100 ;
t = 0:10^7 ;
Then, we enter our model for the concentration in the lake :
c_L = c_i.*(1-exp((-r.*t)./V));
Finally, we plot the evolution of the concentration in the lake:
plot(t,c_L);
semilogx(c_L);
xlabel("Time t (hours)");
ylabel("Concentration of pollutant in the lake cL (kg/m^3)");
title("Concentration vs time");

采纳的回答

Star Strider
Star Strider 2021-2-1
Try this:
r = 10^5 ;
V = 10^10 ;
c_i = 100 ;
t = logspace(-2, 7, 20);
c_L = c_i.*(1-exp((-r.*t)./V));
Q1 = nnz(diff(c_L)==0)
c_crit = 0.331;
t_crit = interp1(c_L, t, c_crit);
figure
plot(t,c_L);
hold on
plot(t_crit, c_crit, 'sr', 'MarkerFaceColor','r')
hold off
set(gca, 'XScale','log', 'YScale','log')
% semilogx(c_L);
xlabel("Time t (hours)");
ylabel("Concentration of pollutant in the lake cL (kg/m^3)");
title("Concentration vs time");
text(t_crit, c_crit, sprintf(' \\leftarrow t = %5.1f, Concentration = %6.3f', t_crit, c_crit), 'HorizontalAlignment','left', 'VerticalAlignment','middle')
Change it to produce the result you want.
  2 个评论
Leonor Vieira Dias
that work out very well! thank you very much
Star Strider
Star Strider 2021-2-1
As always, my pleasure!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by