ODE with Matrices Galerkin

6 views (last 30 days)
Alexander Wilcox
Alexander Wilcox on 7 Mar 2019
Answered: darova on 7 Mar 2019
I have a second order differential equation that I need to solve for a column vector of length 16. In matrix from the equation is [K][a]+[Cq]=p[M][a'']. I know the value of K, a 16x16 matrix with non-variable terms, Cq is a column vector of length 16 with each row the same function of time. p is the density in the problem and [M][a''] is the inertial part of the problem. How can I use MATLAB ODE solvers to solve for the [a] vector values.
Attached is "Ktot.m" which is the 16x16 matrix [K]
[Cq] is a column vector of length 16 where each row is (21.7e6*heaviside(x-0.1778)-21.7e6*heaviside(x-0.3178))*(23.8e6*heaviside(y-0.018)-23.8e6*heaviside(y-0.145))*dirac(t-1)

Answers (1)

darova
darova on 7 Mar 2019
function mathworks
xspan = [0 0.8];
y0 = ... % initial conditions (vector of 32)
[x, y] = ode45(@func_trap, xspan, y0);
% y(:, 1:16) = y
% y(:,17:32) = y'
plot(x,y(:,1))
hold on
plot(x,y(:,2))
...
hold off
end
function da = func(x,y)
% y(1:16) = y
% y(17:32) = y'
da = zeros(32,1);
da(1:16,1) = y(17:32);
K = ...
a = ...
Cq = ...
p = ...
M = ...
da
dda = inv(p*M)*(K*a + Cq);
da(1:16) = y(17:32);
da(17:32) = dda(1:16);
end

Community Treasure Hunt

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

Start Hunting!