clear all; close all; clc
% time
T = 0.25;
Nu = 140; % an integer number of time steps in one period
dt = 1/Nu;
k = 3;
% quadrature points and weights
xi = [-0.906179845938664, -0.538469310105683, .
0, 0.538469310105683, 0.906179845938664];
w = [0.2369268
function RHS = ForcingTerm (u,J,M,dx,q)
% stiffness matrix A
B = zeros(M+1);
for m = 1:M+1
for n = 1:M+1
if mod(m,2) = 0 & mod(n,2) = 0
B(m,n) = 0;
elseif mod(m,2) ~= 0 & mod(n,2) ~= 0
B(m,n) = 0;
elseif m <= n
B(m,n) = 0;
else
B(m,n) = 2;
end
end
end
A =
function Q = initfuncQ (L, J, x)
for i = 1:J
for j = 1:length(x(1,:)
if (abs(x(i,j)-0.5) < L)
Q(i,j) = (cos(pi/2)*(x(i,j)-0.5)/L)^2;
else
Q(i,j) = 0;
end
end
end
end