How can i find the value in one point of the graph?

7 views (last 30 days)
Hi guys
So, I have this script with a equation of a curve and a I created a tangent line to find a value on the y axis
thb=nlinfit(t,hb,f,alfa0);
hbf=thb(1)+thb(2)*(thb(3).^t); %(curve equation)
tponto=3000.0;
dhbfdt=(thb(2)*log(thb(3)))*thb(3)^tponto;
declive=dhbfdt;
iponto=find(t==tponto);
hponto=hbf(iponto)
imax=length(t);
hlinear=zeros(imax,1);
for i=1:imax
hlinear(i)=hponto+declive*(t(i)-tponto); %(tangent line)
end
figure(2)
hold on
plot(t,hb,'o','LineWidth',2)
plot(t,hbf,'-','LineWidth',2)
plot(t,hlinear);
axis([0 7200 0 0.25])
xlabel('Tempo/s')
ylabel('Altura da Interface/m')
hold off
I want to know the value of y in this red dot. How can I do this?
Thank you

Accepted Answer

Star Strider
Star Strider on 28 Apr 2017
The red dot appears to be the y-intercept, so my guess would be that it is ‘hponto’. It would help to have your plot calls to see what you actually plotted.
  7 Comments
Eryk Fernandes
Eryk Fernandes on 29 Apr 2017
I used a derivative to find de slope of the line, the hponto is point that the line is tangent to. hponto=0.03562
Star Strider
Star Strider on 29 Apr 2017
If you know the slope at a point in the line and the x and y coordinates of any point on it, it is straightforward to calculate the y-intercept:
Start with:
y_coordinate = slope*x_coordinate + y_intercept
then solve for y_intercept:
y_intercept = y_coordinate - slope*x_coordinate
That produces the value you want, and also defines your entire equation for the line.
I cannot follow your code, so I am not using your variable names.

Sign in to comment.

More Answers (0)

Categories

Find more on Discrete Data Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!