create_H_matrix

# create_H_matrix - Author Andrew Harms Date Copyright(c 2013...

• Test Prep
• 1

This preview shows page 1 out of 1 page.

% Author: Andrew Harms % Date: 03/31/2013 % Copyright (c) 2013 by Andrew Harms. This work is made available under % the terms of the Creative Commons Attribution-ShareAlike 3.0 license function H = create_H_matrix(R,W) % Create summation-operation matrix (size R x W). If W/R is not an % integer, then split entries between rows. W and R should be integers. if W < R

Unformatted text preview: error('Cannot use W < R'); else H = zeros(R,W); r=0; k=0; for i=1:R index1 = floor(W/R-(1-r)); next_r = round(W-R*index1-R*(1-r))/R; M = [(1-r) ones(1,index1) next_r*ones(1,next_r>0)]; r = next_r; H(i,:) = [zeros(1,k) M zeros(1,W-k-length(M))]; if r k = k + (length(M)-1); else k = k + length(M); end end % for end % if W < R end % function...
View Full Document

• Fall '15
• Ring, Lawrence Lessig, Andrew Harms, 2013 %

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern