using gradient with ode45
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
jose luis guillan suarez
el 6 de Jul. de 2018
Comentada: jose luis guillan suarez
el 19 de Jul. de 2018
i have this code, where gradient(u,t) should be the derivative of u:
function [xdot]=pid_practica9_ejercicio3_ec_diferencial_prueba2(t,x)
Vp=5;
u=Vp*sin(2*pi*t)+5;
xdot = [
x(2, :);
1.776*0.05252*20*gradient(u,t)-10*x(1, :)-7*x(2, :);
];
%[t,x]=ode45('pid_practica9_ejercicio3_ec_diferencial_prueba2',[0,10],[0,0])
% plot(t,x)
but in the solution i get only zeros (and they shouldn't be)
is it possible to work with a derivative in the definition of a diferential equation like i do?
2 comentarios
jose luis guillan suarez
el 7 de Jul. de 2018
Editada: Walter Roberson
el 7 de Jul. de 2018
Respuestas (1)
Walter Roberson
el 7 de Jul. de 2018
The t and x values passed into your function will be purely numeric, with t being a scalar and x being a vector the length of your initial conditions (so a vector of length 2 in this case.)
You calculate u from the scalar t value, and you pass the scalar u and scalar t into gradient -- the numeric gradient routine. The numeric gradient() with respect to scalar F and scalar H is always 0.
8 comentarios
Ver también
Categorías
Más información sobre Ordinary Differential Equations 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!