Drawing a tangent line (concave line) for a curve

조회 수: 2 (최근 30일)
Abdulrahman Alzailaie
Abdulrahman Alzailaie 2020년 2월 22일
답변: Devineni Aslesha 2020년 2월 25일
I would like to draw the line in red, i.e. the steepest line starting from (1,0) and touching the CSTR line, using MATLAB (picture attached).
Here is my code:
global k to CA0
CA0= 1;
k= [0.01 5 10 100];
tspan= [0:0.001:8];
C_init= [CA0 0]';
ts= 0.001; %step time
tf=8; %final time
tx= 0; %counter
sze= 1+ (tf/ts); %size (for loop)
for x= 1 : sze
to= tx;
CSTR= (fsolve(@ZMA, C_init))';
tx = tx + ts;
sTore(x,:)= CSTR;
end
plot(sTore(:,1), sTore(:,2)); %plot CA vs. CB
title('[A] vs. [B]')
%For CSTR
function CAB = ZMA(C)
global k to CA0
fA= to*(k(1) * C(1) - k(2) * C(2) + k(4) * C(1)^2) - CA0 + C(1);
fB= to*(k(1) * C(1) - k(2) * C(2) - k(3) * C(2)) - C(2);
CAB = [fA;fB];
end

답변 (1개)

Devineni Aslesha
Devineni Aslesha 2020년 2월 25일
Considering the curve equation as f(x), find the derivative of the curve w.r.to the variable the curve depends on i.e. ‘x’. Evaluate the derivative at the given point on the curve i.e. ‘x0’. The tangent is obtained from the line equation as shown below.
y = f(x0) + f’(x0)*(x – x0);

카테고리

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