ODE with Matrices Galerkin

조회 수: 6 (최근 30일)
Alexander Wilcox
Alexander Wilcox 2019년 3월 7일
답변: darova 2019년 3월 7일
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)

답변 (1개)

darova
darova 2019년 3월 7일
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

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by