Effacer les filtres
Effacer les filtres

using gradient with ode45

6 vues (au cours des 30 derniers jours)
jose luis guillan suarez
jose luis guillan suarez le 6 Juil 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 commentaires
madhan ravi
madhan ravi le 7 Juil 2018
Can you post the question to solve?
jose luis guillan suarez
jose luis guillan suarez le 7 Juil 2018
Modifié(e) : Walter Roberson le 7 Juil 2018
this is the equation:
Vp=5;
u=Vp*sin(2*pi*t)+5;
x''=-7x'-10x+1.776*0.05252*20*u'

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 7 Juil 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 commentaires
jose luis guillan suarez
jose luis guillan suarez le 12 Juil 2018
my problem is that i'm trying to represent this system with differential equations and with ode45, where the derivative of u is needed (if im not commiting a mistake), and it is perfectly representable in matlab using the blocks (in the 's' domain) and with the input as a step input (which is very similar to a squared waveform)
jose luis guillan suarez
jose luis guillan suarez le 19 Juil 2018
i simulated this system with a step input with this instructions:
>> num1=20
num1 =
20
>> den1=[1 7 10]
den1 =
1 7 10
>> sys1=tf(num1,den1)
sys1 =
20
--------------
s^2 + 7 s + 10
Continuous-time transfer function.
>> num2=[1 0]
num2 =
1 0
>> den2=1
den2 =
1
>> sys2=tf(num2,den2)
sys2 =
s
Continuous-time transfer function.
>> sys=series(sys1,sys2)
sys =
20 s
--------------
s^2 + 7 s + 10
Continuous-time transfer function.
>> step(sys)
and i obtain this response:
but it seems to be impossible to simulate it with diferential equations

Connectez-vous pour commenter.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by