## Differential Algebraic Equations with vectors

Maulidi

### Maulidi (view profile)

さんによって質問されました 2019 年 11 月 11 日

### Maulidi (view profile)

さんによって コメントされました 2019 年 11 月 12 日
darova

### darova (view profile)

さんの 回答が採用されました
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
Invalid equations.
T = feval(symengine,'symobj::dsolve',sys,x,options);
Error in dsolve (line 194)
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);

darova

### darova (view profile)

on 11 Nov 2019
DO you have originla formulas/equations? Pictures?
Maulidi

### Maulidi (view profile)

2019 年 11 月 12 日 サインイン to comment.

R2018b

## 1 件の回答

### darova (view profile)

on 12 Nov 2019

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);

Maulidi

### Maulidi (view profile)

on 12 Nov 2019
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 (view profile)

on 12 Nov 2019
You want to find h and theta First row of this system can be re-written as  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 (view profile)

2019 年 11 月 12 日
Awesome explanation. Much appreciated.

サインイン to comment.