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

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

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

Sorry, forgot about that
But the hponto is the point which the line pass tangentially
No worries!
The important aspect is that we solved your problem.
Still, how can I find the value of y on the red dot?
If the red dot is the y-intercept and if ‘hponto’ is the y-intercept of a linear fit, it should be ‘hponto’. The only ‘red dot’ I see on your plot is at ‘t=0, y=0.75 (approximately)’.
If the ‘red dot’ is something else, I need to know what it is, and have your data and the objective function ‘f’ you used so I can run your code and calculate it. You can post your code. It would be best to Attach your data as a ‘.mat’ file to your original Question or to a Comment here.
I cannot understand what you are doing without this information.
What criteria do you use to calculate the tangent line? At what point is it tangent to? How do you determine that point?
I used a derivative to find de slope of the line, the hponto is point that the line is tangent to. hponto=0.03562
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 2-D and 3-D 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!