How to find the slope of the curve at x=0 and y=0

조회 수: 2 (최근 30일)
NITHIN XAVIER
NITHIN XAVIER 2019년 8월 4일
편집: Star Strider 2019년 8월 4일
I wanted to find the slope of the curve, where is cross the x-axis and y-axis (there are four points), I am a beginner in Matlab, It would be very helpful if someone can help me.
Thanks in advance.
IV curve.jpg
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 8월 4일
Do you have the equations, and do you have the symbolic toolbox? If so then evaluate the derivatives at the appropriate points.
darova
darova 2019년 8월 4일
I want to help you

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

답변 (1개)

Star Strider
Star Strider 2019년 8월 4일
편집: Star Strider 2019년 8월 4일
Since you did not share your data, I created my own.
This should get you started:
x = linspace(-0.5, 1.5); % Create Data
y1 = 20*exp(0.8*x)-25; % Create Data
y2 = 15*exp(1.2*x)-35; % Create Data
dv = [-1 0 1]*1E-7;
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector
y1zx = zci(y1); % Zero-Crossing Indices
dy1dx = gradient(y1,(x(2)-x(1))); % Numerical Derivative
y1y0x = interp1([y1(y1zx(1)-1),y1(y1zx(1)+1)],[x(y1zx(1)-1),x(y1zx(1)+1)],0); % Precise Zero-Crossing
dy1y0 = interp1([x(y1zx(1)-1),x(y1zx(1)+1)],[dy1dx(y1zx(1)-1),dy1dx(y1zx(1)+1)],y1y0x); % ‘y1’ Slope At y=0 ***
y2zx = zci(y2); % Zero-Crossing Indices
dy2dx = gradient(y2,(x(2)-x(1))); % Numerical Derivative
y2y0x = interp1([y2(y2zx(1)-1),y2(y2zx(1)+1)],[x(y2zx(1)-1),x(y2zx(1)+1)],0); % Precise Zero-Crossing
dy2y0 = interp1([x(y2zx(1)-1),x(y2zx(1)+1)],[dy2dx(y2zx(1)-1),dy2dx(y2zx(1)+1)],y2y0x); % ‘y2’ Slope At y=0 ***
x0 = find(x>=0, 1, 'first');
dy1x0 = interp1([x(x0-1),x(x0+1)],[dy1dx(x0-1),dy1dx(x0+1)],0); % ‘y1’ Slope At x=0 ***
dy2x0 = interp1([x(x0-1),x(x0+1)],[dy2dx(x0-1),dy2dx(x0+1)],0); % ‘y2’ Slope At x=0 ***
figure
plot(x, y1, x, y2)
grid
txtcely0 = sprintfc('\\leftarrow Slope = %.3f', [dy1y0, dy2y0]);
txtcelx0 = sprintfc('Slope = %.3f \\rightarrow', [dy1x0, dy2x0]);
text([y1y0x, y2y0x],[0 0], txtcely0, 'HorizontalAlignment','left', 'Rotation',-45)
text([0, 0],[y1(x0) y2(x0)], txtcelx0, 'HorizontalAlignment','right')
The slope results are signified by ‘***’ at the end of the comments.
EDIT — Added plot & text Calls.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by