Write a Matlab M-code program which solves the Finite Difference equations for the unknown temperatures Ti where the value of N, the number of internal nodes in the vertical direction, is specified as a parameter at the beginning of the program. Your program should also do the following.
- Write the numerical values of temperature and the corresponding value of the analytical solution to this problem, T=xy, at each of your grid points, to a text file.
- Calculate the maximum percentage difference between your numerical solution and the analytical solution in the form 100[(numerical - analytical) / analytical] over all the grid points and write this value to the same text file to which you have written the numerical and analytical results.
You are asked to hand in the following:
(i) A copy of your Matlab M-code program, which is documented similarly to the programs you have been given during the lectures, together with your results file for the case with N=4, which show the numerical and analytical values at each grid point and which contains the maximum percentage difference between the analytical and numerical solution over the entire grid of 40 points.
(ii) A sheet on which you have derived (i.e. do not simply write them down) the Finite Difference equations for the above grid with N=4 (and a total of 40 unknowns) at nodes 1 and 40.
(iii) Generate a 3-D plot of the temperature against x and y including the boundary values, e.g. using the Matlab function surf.
When writing your program you may find it useful to populate your temperature matrix by considering the equations at the following nodes separately:
i. All nodes not influenced by the boundary conditions, i.e. those not adjacent to the boundaries.
ii. Each of the four corner nodes separately
iii. Nodes adjacent to the bottom (y=0) boundary but not at the corners
iv. Nodes adjacent to the left boundary (x=0) but not at the corners
v. Nodes adjacent to the upper boundary (y=1) but not at the corners.
vi. Nodes on the right hand boundary (x=2) but not at the corners.
Note that for the grid given above these different sections would be
i. Nodes 12-19, 22-29.
ii. Nodes 1, 10, 31, 40
iii. Nodes 2-9
iv. Nodes 11, 21
v. Nodes 32-39.
vi. Nodes 20, 30.
Attachment:- MATLAB.pdf