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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started