x-intersection of part of extended line from curve
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Akhtar Rind
el 12 de Ag. de 2020
Comentada: Star Strider
el 13 de Ag. de 2020
Hello There.
I have plot which looks below. Part of curve which behave like straight line such as red highlighted part. I want extend this red line and find time when it intersects with horizonal axis (Time).
The initial code is provided with redline part. I will be using this method to analyses many other similar types of graphs.

0 comentarios
Respuesta aceptada
Star Strider
el 12 de Ag. de 2020
Add these lines to your code after the ‘m’ calculation and before figure(1):
B = [TC ones(size(TC))] \ IC; % Fit Red Line (Estimate Parameters)
Slope = B(1);
YIntercept = B(2);
XIntercept = -YIntercept / Slope % Calculate X-Intercept
ExtLine = [[TC(1); XIntercept] ones(size(TC))] * B % Y-Coordinates
and after the first hold call:
plot([TC(1); XIntercept], ExtLine, '-g') % Plot Line
The x-intercept is 1.4494 microseconds.
.
5 comentarios
Star Strider
el 13 de Ag. de 2020
Correct. That was a typo on my part. (Still too early for me here!) They are labeled correctly in my code. The angles were calculated from the ‘Slope’ variable, so they are correct.
Más respuestas (1)
Alan Stevens
el 12 de Ag. de 2020
Editada: Alan Stevens
el 12 de Ag. de 2020
You can use the following relation:
( max(y_redline_value) - min(y_redline_value) ) / ( max(x_redline_value) - min(x_redline_value) )=
( max(y_redline_value) - 0 ) / ( max(x_redline_value) - x_desired )
Rearrange to get x_desired (i.e. the value of the straight line intercept on the x-axis).
Ver también
Categorías
Más información sobre Line Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!