How to draw the tangent line on a curve

조회 수: 102 (최근 30일)
Inou
Inou 2021년 6월 29일
댓글: Star Strider 2022년 1월 23일
I would like to plot the tangent of the curve I (V) and find the slope and then the intersection of the tangent with the x axis (V0).
I am attaching the curve data (I, U) and a summary image of what I am looking for. Thank you in advance for your help

채택된 답변

Star Strider
Star Strider 2021년 6월 29일
Try this —
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/668953/Tan.xlsx')
T1 = 42×2 table
I V ______ ________ 0 0 0 0.064516 0 0.14337 0 0.20072 0 0.36559 0 0.45878 4.6681 0.55197 19.593 0.63799 40.963 0.73118 58.96 0.7957 79.604 0.86022 114.14 0.9534 138.19 1.0108 164.38 1.0681 181.86 1.1039 207.75 1.1541
I = T1.I;
V = T1.V;
dI = gradient(I);
dV = gradient(V);
Vi = 1.3; % Choose Voltage Value To Calculate Slope
Ii = interp1(V, I, Vi);
dVi = interp1(V, dV, Vi)
dVi = 0.0299
dIi = interp1(V, dI, Vi)
dIi = 18.8851
Slope = dIi/dVi
Slope = 631.9586
YIntercept = Ii - Slope * Vi
YIntercept = -528.9232
XIntercept = -YIntercept / Slope
XIntercept = 0.8370
figure
plot(V,I)
hold on
plot(Vi, Ii, 'p')
plot(xlim, xlim*Slope+YIntercept, '-r')
plot(XIntercept, 0, 'sr')
hold off
grid
xlabel('V')
ylabel('I')
text(Vi, Ii, sprintf('$I = %.3f \\times V %+.3f \\rightarrow \\ $', Slope, YIntercept), 'Horiz','right', 'Vert','middle', 'Interpreter','latex')
text(XIntercept, 0, sprintf('$%.4f V \\downarrow $', XIntercept), 'Horiz','right', 'Vert','bottom', 'Interpreter','latex')
ylim([0 max(ylim)])
.
  댓글 수: 6
Sharatkumar Kondikoppa
Sharatkumar Kondikoppa 2022년 1월 23일
In your code you have taken Vi =1.3 , did you choose randomly or took a mean value ? Can you explain me.
Or can I choose any value ?
Star Strider
Star Strider 2022년 1월 23일
I chose that value for ‘Vi’ since although the exact point was not stated, it was certainly implied in the ‘image001.png’ plot.
So ‘Vi’ can be any point in the curve.

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

추가 답변 (1개)

Asmit Singh
Asmit Singh 2021년 6월 29일
This answer might be useful.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by