필터 지우기
필터 지우기

Mark a point on graph

조회 수: 2 (최근 30일)
Leonor Vieira Dias
Leonor Vieira Dias 2021년 2월 1일
댓글: Star Strider 2021년 2월 1일
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
Leonor Vieira Dias 2021년 2월 1일
that work out very well! thank you very much
Star Strider
Star Strider 2021년 2월 1일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Title에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by