Variation of initial values and slope calculation
Afficher commentaires plus anciens
Hi everyone,
I'd like to plot a function with different initial values, and calculate the slope(v0) between the 2. and 3. point, but it doesn't work. Could you please help me.
Thank you!!
Hier is my code:
% Main program
n=15;
s00=logspace(1,3,n);
for k=1:n;
s0=s00(k);
v0(k)=(x(4)(3)-x(4)(2))/(t(3)-t(2));
end
e0=2;
c0=0;
p0=0;
t=linspace(0,1000,100);
x0=[s0 c0 e0 p0];
[t,x]=ode45(@(t,x) num_lsg1(t,x), t, x0); % function call
%figure
plot(t,x(:,4),'-*')
hold all;
xlabel('Time [s]');
ylabel('Product');
%%Definition function
function dx=num_lsg1(t,x)
% Definition parameters
k1=0.01;
km1=10^(-6);
k2=1;
dx=zeros(4,1);
dx(1) = km1*x(2)-k1*x(1)*x(3);
dx(2) = k1*x(1)*x(3)-(km1+k2)*x(2);
dx(3) = (km1+k2)*x(2)-k1*x(1)*x(3);
dx(4) = k2*x(2);
end
2 commentaires
What do you want to achieve with this (invalid) syntax:
(x(4)(3)-x(4)(2))
in line 6?
Tatjana Henning
le 27 Déc 2018
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Whos dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
