Drawing a tangent line (concave line) for a curve

1 vue (au cours des 30 derniers jours)
Abdulrahman Alzailaie
Abdulrahman Alzailaie le 22 Fév 2020
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

Réponses (1)

Devineni Aslesha
Devineni Aslesha le 25 Fév 2020
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);

Catégories

En savoir plus sur Interpolation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by