Borrar filtros
Borrar filtros

how to find numerical derivative of function inside system of Diff equations ?

1 visualización (últimos 30 días)
I want to solve this system of DE :
function ydot= DRV(y)
B=[1 0.5 4;7.2 0.6 5;3.3 8 0.2];
R1=[2 5 3;11 3 6;1.2 2 4];
Q1=eye(3,3);
qv=[y(1);y(2);y(3)];
p=[y(4) y(5) y(6);y(7) y(8) y(9);y(10) y(11) y(12)];
qvdot=p*qv;
pdot=p*B*inv(R1)*p+Q1;
v=Q1*p*R1*qv;
vdot= % how to derive V with finite difference approximation or any other method
zdot=Q1*v+R1*vdot;
pdot=pdot(:);
ydot=[qvdot;pdot;zdot];
ydot(:);
end
how to find numerical derivative of v without entering the exact expression of it's derivative ?
then solve the DRV function
clc;clear ALL;close all;
[t,y]=ode45(@(t,y)DRV(y),[0 10],[0.8224 0.2226 0.4397 0.3604 -1.5 -5.9 -6.5 0 0 0 0 0 0 0.1 0.2])
  3 comentarios
Waleed new
Waleed new el 23 de Jul. de 2018
Editada: Waleed new el 23 de Jul. de 2018
yes i can differentiate v with pencil or with symbolic computation in Matlab but I want to see how to do it with finite difference approximation method :
dv(x)/dx=( v(x+delta_x) - v(x) )/delta_x
or like the derivative block in simulink (Output time derivative of input)
Jan
Jan el 23 de Jul. de 2018
Then you have to define a suitable delta_x. This is not trivial, because the cancellation error and the discretization error compete with each other. To find the optimal step width, the 2nd derivatives are required, but usually expensive.
A rough estimation might be delta_x = sqrt(eps(v)) and then try the formula you have given already. A two sided differential quotient is more stable, but twice as expensive.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Statics and Dynamics en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by