MATLAB Answers

Differential Algebraic Equations with vectors

6 views (last 30 days)
Maulidi on 11 Nov 2019
Commented: Maulidi on 12 Nov 2019
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
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);
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
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 on 11 Nov 2019
DO you have originla formulas/equations? Pictures?

Sign in to comment.

Accepted Answer

darova on 12 Nov 2019
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)
[t,u] = ode45(F,timespan,IC);


Maulidi 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 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 on 12 Nov 2019
Awesome explanation. Much appreciated.

Sign in to comment.

More Answers (0)

Sign in to answer this question.