Question: In a Matlab script create a standard non-sparse matrix with size 500 3 (500 rows, 3 columns). All entries in columns 1 and 3 should

In a Matlab script create a standard non-sparse matrix with size 500 3 (500 rows, 3 columns). All entries in columns 1 and 3 should be 1 and all entries in column 2 should have the value 2.

Use the spdiags function to create a 500 500 sparse tri-diagonal matrix, A. The diagonal and 2 off-diagonals should be the columns of the 500 3 matrix. Next create a non-sparse version of A (using the `full' function) and call it B. Use the `whos' command to compare the sizes (in computer memory) of the 2 matrices. Using the `tic' and `toc' functions compare how long it takes to calculate A^2 and B^2 . Is there much of a difference?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!