REC11+Problems+Set+Solutions+SAMPLE

REC11+Problems+Set+Solutions+SAMPLE - 14:440:127...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
14:440:127 Introduction to Computers for Engineers Recitation 11 - Problems for students to attempt - SAMPLE SOLUTIONS PROBLEM 4 Create a 1000x1000 matrix full of zeros, but set nonzero values for 5 of those elements. Now, convert it to a sparse matrix (and save in a different variable). Use the whos command to determine which uses less memory. Explain your result. This problem is easy if you read your Lecture 11 Notes . >> b = zeros(1000); >> b(1,1)=43; >> b(2,2)=54; >> b(14,45) = 543; >> b(63,15) = 431; >> b(64,14) = 43; >> bsparse = sparse(b); >> whos Name Size Bytes Class b 1000x1000 8000000 double array bsparse 1000x1000 4064 double array (sparse) The sparse matrix uses much less memory since b contains mostly zeros. PROBLEM 6 Given any integer n, representing the number of lines, write a RECURSIVE solution that outputs the following pattern (here, n=6). (You can use one loop in the solution if you need to, although you cannot use nested loops). Remember to think about the base case and a function
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/24/2011 for the course ENGINEERIN 127 taught by Professor Finch during the Spring '08 term at Rutgers.

Page1 / 3

REC11+Problems+Set+Solutions+SAMPLE - 14:440:127...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online