Question: Please use Matlab 4 Sparse Matrices In this problem you will see how using sparse matrices correctly can improve your code. (a) Use Matlab's gallery

Please use Matlab
4 Sparse Matrices In this problem you will see how using sparse matrices correctly can improve your code. (a) Use Matlab's gallery command to create an na x n matrix A that results from discretizing Poisson's equation with the 5-point operation on an n-by-n mesh. Create a vector b of random values. Write a function x=sparsePoissonSolve(b,n) that computes the solution to Az = b. (Note: If you are using a version of Octave that has not implemented the gallery command, the function setupA.m can be used instead.] (b) Create another matrix, that is the matrix A in full storage organization. Write a function x=fullPoissonSolve(b,n) that computes the solution to Br = b. (C) Write a script that does the following 1. Compute and record the computation time for sparsePoissonSolve where n=10:10:100 2. Compute and record the computation time for fullPoissonSolve where n=10:10:100 3. Plot the computation time versus n for both sparse and full storage in the same graph. Comment on the observed results. 4 Sparse Matrices In this problem you will see how using sparse matrices correctly can improve your code. (a) Use Matlab's gallery command to create an na x n matrix A that results from discretizing Poisson's equation with the 5-point operation on an n-by-n mesh. Create a vector b of random values. Write a function x=sparsePoissonSolve(b,n) that computes the solution to Az = b. (Note: If you are using a version of Octave that has not implemented the gallery command, the function setupA.m can be used instead.] (b) Create another matrix, that is the matrix A in full storage organization. Write a function x=fullPoissonSolve(b,n) that computes the solution to Br = b. (C) Write a script that does the following 1. Compute and record the computation time for sparsePoissonSolve where n=10:10:100 2. Compute and record the computation time for fullPoissonSolve where n=10:10:100 3. Plot the computation time versus n for both sparse and full storage in the same graph. Comment on the observed results
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
