필터 지우기
필터 지우기

Can someone explain to me how to code the Tangent line and Normal line

조회 수: 6 (최근 30일)
Echo Lei
Echo Lei 2022년 10월 4일
댓글: Echo Lei 2022년 10월 4일

채택된 답변

Torsten
Torsten 2022년 10월 4일

추가 답변 (1개)

Davide Masiello
Davide Masiello 2022년 10월 4일
편집: Davide Masiello 2022년 10월 4일
syms x m b yt
f(x) = 3^x+3*x+2; % Function
m = diff(f,x) % Slope of tangent line
m(x) = 
b = f-m*x; % Intercept of tangent line
x0 = randi([-5 5]); % Random point x
b = subs(f,x0)-subs(m,x0)*x0; % Intercept value at random point % Redefine x as symbolic variable
yt(x) = subs(m,x0)*x+b % Tangent line equation at random point
yt(x) = 
fplot(x,f(x)) % Plot function
hold on
fplot(x,yt(x),'r') % Plot tangent
plot(x0,subs(yt,x0),'ok') % Plot point of tangency
You can use the same procedure for the normal line.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by