x-intersection of part of extended line from curve

조회 수: 1 (최근 30일)
Akhtar Rind
Akhtar Rind 2020년 8월 12일
댓글: Star Strider 2020년 8월 13일
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.

채택된 답변

Star Strider
Star Strider 2020년 8월 12일
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
Akhtar Rind
Akhtar Rind 2020년 8월 13일
Star Strider
You mean B(1) as that is the slope. B(2) is YIntercept
Thanks
Star Strider
Star Strider 2020년 8월 13일
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.

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

추가 답변 (1개)

Alan Stevens
Alan Stevens 2020년 8월 12일
편집: Alan Stevens 2020년 8월 12일
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).
  댓글 수: 1
Akhtar Rind
Akhtar Rind 2020년 8월 13일
Thank you very much for explaination. This code worked as well.

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

카테고리

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

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by