Answer to Question #149150 in MatLAB for rock

Question #149150
Write a MATLAB program to solve the following BVP
Solve the following boundary value problem using finite difference method,
with ∆x = ∆y =
1
3
∂
2u
∂x2
+
∂
2u
∂y2
= 0, 0 < x < 1, 0 < y < 1
u(x, 0) = u(0, y) = 0, u(x, 1) = x, u(1, y) = y, 0 ≤ x ≤ 1, 0 ≤ y ≤ 1
1
Expert's answer
2020-12-10T07:50:06-0500
h=0.05; % step size
syms x1 y0 y1 y2 % declaring symbolic variables
dy = (y2-y1)/h; % defining first derivative
d2y= (y2-2*y1-y0)/(h^2); % defining second derivative
f=d2y== -4*x1*dy+(2/(x1^2))*(y1-log(x1)); % defining BVP
% initializing
x=1:h:2;
n=length(x);
y_a=1340; % boundary values
y_b=124;
A=[1 zeros(1,n-1)]; % inserting the first row   
b=[y_a]; % inserting initial value  

for i=2:n-1  
[p q]=equationsToMatrix(subs(f,x1,x(i))); % substituting x_i in BVP
p=[zeros(1,i-2) p zeros(1,n-i-1)]; % zero padding to match matrix size
A=[A;p]; % appending
b=[b;q];   
end
A=[A; zeros(1,n-1) 1];% inserting the last row
b=[b;y_b]; % inserting final value  
Y=A\b;
index=uint8(1+(1.35-1)/h); % finding index for y(1.35)
vpa(Y(index),9) % value of y(1.35)

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS