Question #149144

Write a MATLAB program to solve the following BVPs

. Solve the following PDEs



2u

∂t2

=



2u

∂x2

, 0 < x < 1, t > 0.

u(x, 0) = 0,



∂u

∂t 

(x,0)

= sin3

(πx), 0 ≤ x ≤ 1

u(0, t) = u(1, t) = 0, t ≥ 0.

Expert's answer

% a.
% defining eqn
bvpfcn = @(t,Theta) [Theta(2) -Theta(1)];

% coding boundary condition
bcfcn = @(Ta,Tb) [Ta(1)-0.7  Tb(1)-0.7];

% defining guess function
guess = @(t) [sin(t) cos(t)];

% defing tmesh
tmesh = linspace(0,2*pi,20);
% defining solution
solinit = bvpinit(tmesh, guess);

% solve eqn
sol = bvp4c(bvpfcn, bcfcn, solinit);

% plot sulution
figure;
plot(sol.x, sol.y, '-o');
% label
xlabel("t");
ylabel("Theta");
title("a. t vs Theta");
legend("Theta","Theta'");

% b.
% defining eqn
bvpfcn = @(t,Theta) [Theta(2) -sin(Theta(1))];

% coding boundary condition
bcfcn = @(Ta,Tb) [Ta(1)-0.7  Tb(1)-0.7];

% defining guess function
guess = @(t) [sin(t) cos(t)];

% defing tmesh
tmesh = linspace(0,2*pi,20);
% defining solution
solinit = bvpinit(tmesh, guess);

% solve eqn
sol = bvp4c(bvpfcn, bcfcn, solinit);

% plot sulution
figure;
plot(sol.x, sol.y, '-o');
% label
xlabel("t");
ylabel("Theta");
title("b. t vs Theta");
legend("Theta","Theta'");
CALCULATE THE PRICE

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS