MATLAB Answers

Differential Algebraic Equations with vectors

7 ビュー (過去 30 日間)
Maulidi
Maulidi 2019 年 11 月 11 日
コメント済み: Maulidi 2019 年 11 月 12 日
Hello Guys,
I am trying to solve the following differential algebraic Equation and I keep find the below errors concerning the model resolution. I tried chancing the intial conditions and the variables and its not working. Kindly assist.
clc; clear all;
%differential equation symbolic resolution
syms h(t) theta(t)
%initial or boundary conditions
starttime = 0; finishtime=100; timesteps = 10;
%the span
timespan = linspace(starttime, finishtime, timesteps);
%initial conditions
IC = [h(0) == 0, theta(0) == 0];
% equation setup
odequation1 = diff(h(t), t, t) == (26*h(t))/25 - (11683563954355*theta(t))/1099511627776;
odequation2 = diff(theta(t), t, t) == (4296857747895619*theta(t))/562949953421312 - (400*h(t))/1043 ;
odequations = [odequation1, odequation2]
% different tools
dsolve(odequations, timespan, IC);
%OR either tools not working
vars = [h(t), theta(t)];
diffeqn = matlabFunction(odequations, vars, {'h', 'theta', 't'});
sol = ode45(diffeqn, timespan, IC);
Matlab output
dsolve
Error using mupadengine/feval (line 187)
Invalid equations.
Error in dsolve>mupadDsolve (line 340)
T = feval(symengine,'symobj::dsolve',sys,x,options);
Error in dsolve (line 194)
sol = mupadDsolve(args, options);
ode45
Warning: Function 'h' not verified to be a valid MATLAB function.
Warning: Function 'theta_Var' not verified to be a valid MATLAB function.
Warning: Function 'h' not verified to be a valid MATLAB function.
Warning: Function 'theta_Var' not verified to be a valid MATLAB function.
Error using sym/diff (line 36)
Second and third argument must either be variables or a variable and a nonnegative integer specifying the number of differentiations.
Error in
symengine>@(h,t,theta)deal([(diff(h(t),t,t)==diff(h(t),t,t))==h(t).*(2.6e1./2.5e1)-theta(t).*1.062613951431103e1,diff(theta(t),t,t)==h(t).*(-3.835091083413231e-1)+theta(t).*7.63275264840434],[h(t),theta(t)],[h,theta,t])
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);

  2 件のコメント

darova
darova 2019 年 11 月 11 日
DO you have originla formulas/equations? Pictures?
Maulidi
Maulidi 2019 年 11 月 12 日
Equation.PNG

サインイン to comment.

採用された回答

darova
darova 2019 年 11 月 12 日
Try
f = @(t,u) inv(Z)*(J+p*W*pi*Q)*[u(3) u(4)]' + inv(Z)*(V+p*W*pi*Q)*[u(1) u(2)]';
F = @(t,u) [u(3)
u(4)
f(t,u)];
[t,u] = ode45(F,timespan,IC);

  3 件のコメント

Maulidi
Maulidi 2019 年 11 月 12 日
Works fine, I appreciate it. But could you please provide some little explanation on your code or point me towards some literature on your strategy. Thank you very much sir.
darova
darova 2019 年 11 月 12 日
You want to find h and theta
123.PNG
First row of this system can be re-written as
1233.PNG
So i wrote all this as
u(1) % h(t)
u(2) % theta(t)
u(3) % dh(t)
u(4) % dtheta(t)
And system of diff equations:
du(1) = u(3);
du(2) = u(4);
du(3) = % something that depends on (h,theta,dh,dtheta)
du(4) = % something that depends on (h,theta,dh,dtheta)
See more ode45
Maulidi
Maulidi 2019 年 11 月 12 日
Awesome explanation. Much appreciated.

サインイン to comment.

その他の回答 (0 件)

サインイン してこの質問に回答します。

製品


リリース

R2018b

Translated by