フィルターのクリア

using gradient with ode45

6 ビュー (過去 30 日間)
jose luis guillan suarez
jose luis guillan suarez 2018 年 7 月 6 日
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 Center および File ExchangeOrdinary Differential Equations についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by