I have a 14 equation system of second order differential equations which I am trying to solve using dsolve. The program just keeps running without finishing ?

2 views (last 30 days)
This is the script: A is 14x14 matrix
syms x1(t) x2(t) x3(t) x4(t) x5(t) x6(t) x7(t) x8(t) x9(t) x10(t) x11(t) x12(t) x13(t) x14(t);
X = [x1;x2;x3;x4;x5;x6;x7;x8;x9;x10;x11;x12;x13;x14];
syms E;
syms alpha;
f = [(k/m) * E * cos(alpha*t);0;0;0;0;0;0;0;0;0;0;0;0;0];
odes = diff(X,2) == A*X + f;
%odes = diff(X,2) == A*X;
%V = odeToVectorField(odes)
%M = matlabFunction(V,'vars',{'t','E','alpha','Y'})
[x1Sol(t),x2Sol(t),x3Sol(t),x4Sol(t),x5Sol(t),x6Sol(t),x7Sol(t),x8Sol(t),x9Sol(t),x10Sol(t),x11Sol(t),x12Sol(t),x13Sol(t),x14Sol(t)] = dsolve(odes);
x1Sol(t) = simplify(x1Sol(t))
x2Sol(t) = simplify(x2Sol(t))
x3Sol(t) = simplify(x3Sol(t))
x4Sol(t) = simplify(x4Sol(t))
x5Sol(t) = simplify(x5Sol(t))
x6Sol(t) = simplify(x6Sol(t))
x7Sol(t) = simplify(x7Sol(t))
x8Sol(t) = simplify(x8Sol(t))
x9Sol(t) = simplify(x9Sol(t))
x10Sol(t) = simplify(x10Sol(t))
x11Sol(t) = simplify(x11Sol(t))
x12Sol(t) = simplify(x12Sol(t))
x13Sol(t) = simplify(x13Sol(t))
x14Sol(t) = simplify(x14Sol(t))
Would really appreciate help on this.
  4 Comments

Sign in to comment.

Answers (1)

darova
darova on 29 Nov 2019
alpha and E should be numerical
function main
m = 15000;
k = 150000;
n = 14;
A = zeros(n);
A(n,n) = -k/m;
A(n,n-1) = k/m;
for i=1:n-1
A(i,i) = -2*k/m;
A(i+1,i) = k/m;
A(i,i+1) = k/m;
end
f = zeros(n,1);
x0 = ones(2*n,1);
ts = [0 5];
[t,X] = ode45(myode,ts,x0);
plot(t,X)
function dx = myode(t,x)
dx = zeros(2*n,1);
f(1) = k/m * E * cos(alpha*t);
dx(1:n) = x(n+1:end);
dx(n+1:end) = A*x(1:n) + f;
end
end
  2 Comments
Tapas Peshin
Tapas Peshin on 29 Nov 2019
Question:
  1. In my case alpha, E and t are unknowns so I am using symbolic values ?
  2. It is a second order differential equation system. Isn't your solution with ode45 for first order ?
Thanks for the help.

Sign in to comment.

Tags

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!