using gradient with ode45

조회 수: 6 (최근 30일)
jose luis guillan suarez
jose luis guillan suarez 2018년 7월 6일
댓글: jose luis guillan suarez 2018년 7월 19일
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
madhan ravi
madhan ravi 2018년 7월 7일
Can you post the question to solve?
jose luis guillan suarez
jose luis guillan suarez 2018년 7월 7일
편집: Walter Roberson 2018년 7월 7일
this is the equation:
Vp=5;
u=Vp*sin(2*pi*t)+5;
x''=-7x'-10x+1.776*0.05252*20*u'

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2018년 7월 7일
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
jose luis guillan suarez
jose luis guillan suarez 2018년 7월 12일
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 2018년 7월 19일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by