This is a matlab coding question. Please you can take a screen shot of the code
ID: 3282139 • Letter: T
Question
This is a matlab coding question. Please you can take a screen shot of the code in matlab with full detail and comments and post it here.
Problem 2.1 The template script for this question has been written to start you off on the process of solving the Dirichlet boundary value problem: dx2 with f(r) - sin(Tx). You must complete the script however, as it is only half written! You will have to define the boundary conditions as ? and ?, define the RHS function f(r) and then properly create the matrix A as defined in the module notes. Once this is complete, plot your solution as a function of r in a figure by the name 'Figl', ensuring that it satisfies the boundary conditions that you have prescribed. On the same set of axes in Figl overlay the eract solution to the BVP (which you should easily be able to determine with a pen and paper!). Do the solutions match? Hint when plotting the exact solution, use a different r grid (we have started you off by calling it 'xx'), with say 1000 points in between 0 and 1 instead of the r grid with which you found the numerical solution. This ensures that the exact solution will look nice and smooth! Play around with the grid spacing (by modifying the number of node points M in the template) that the numerical solution better approximates the exact solution with a smaller value of Ar (more grid points in ). This scheme exhibits O(Ar2) accuracy,Explanation / Answer
fplot( thetaSol(x) , [ 0 100] ); % Plotting the exact solution
% Finding the numerical solution
% Converting given D.E. into a set of two first order D.E.
% THT = [ theta , theta' ] = [ theta , zeta ]
% So, theta' = zeta and zeta' = - t
% Subject to, theta(0) = alpha and zeta(0) = beta
Dtheta = diff(theta);
zeta = Dtheta;
Dzeta = diff(zeta);
Dzeta == -t;
theta(0) = alpha;
zeta(0) = beta;
THT = [ theta , zeta ];
% Plotting the numerical solution
plotpoints := [[t[i], op(THT[i])] $ i = 0..100]:
plot (plot::PointList2d(plotpoints, PointColor = RGB::Black)):
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.