Start with a matrix of zeros, change all the values to 1 individually through a nested for loop, then use another nested for loop to change some of them back to zeros.
The author at least deserves credit for preallocating memory.
This is why so much effort was put into implementing JIT.

Here is the entirety of what is in this file:

function [G]=bandmatrix(n,k1,k2)
G=zeros(n,n);
for i=1:n
for j=1:n
G(i,j)=1;
end
end
for i=1:n
for j=1:n
if (j<i-k1) G(i,j)=0;
end
if(j>i+k2) G(i,j)=0;
end
end
end

Caitlin, why did you submit two identical files? Did you do this by mistake, perhaps?
Also, you really should at least familiarize yourself with the ONES function in MATLAB, it would be most useful in your function...

Start with a matrix of zeros, change all the values to 1 individually through a nested for loop, then use another nested for loop to change some of them back to zeros.
The author at least deserves credit for preallocating memory.
This is why so much effort was put into implementing JIT.
Here is the entirety of what is in this file:
function [G]=bandmatrix(n,k1,k2)
G=zeros(n,n);
for i=1:n
for j=1:n
G(i,j)=1;
end
end
for i=1:n
for j=1:n
if (j<i-k1) G(i,j)=0;
end
if(j>i+k2) G(i,j)=0;
end
end
end

Comment only