20x20 is not large by any measure I would ever imagine. 20000x20000 might be large. :) Of course, large is a purely subjective adjective, so is defined by the eyes of the beholder. Ok, large for some.
It sounds like you want a tridiagonal matrix, with -2 on the main diagonal, and 1 on the immediate sub and super-diagonals.
Anyway, why are you trying to use toeplitz? Surely you could have used diag simply enough.
As an example, I'll create a 10x10 matrix here to not overburden the window.
Mat1 = -2*eye(n) + diag(ones(1,n-1),-1) + diag(ones(1,n-1),1)
Mat1 =
-2 1 0 0 0 0 0 0 0 0
1 -2 1 0 0 0 0 0 0 0
0 1 -2 1 0 0 0 0 0 0
0 0 1 -2 1 0 0 0 0 0
0 0 0 1 -2 1 0 0 0 0
0 0 0 0 1 -2 1 0 0 0
0 0 0 0 0 1 -2 1 0 0
0 0 0 0 0 0 1 -2 1 0
0 0 0 0 0 0 0 1 -2 1
0 0 0 0 0 0 0 0 1 -2
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Remember there are always many ways to solve a problem. So if you just needed a tridiagonal matrix, that would have worked. Alternatively, you could have don it all in one call to spdiags. Again, many ways to solve any one problem, all of which are often equally as good. Gosh, we could have done it as easily using tril and triu...
-3*eye(n) + tril(triu(ones(n),-1),1)
ans =
-2 1 0 0 0 0 0 0 0 0
1 -2 1 0 0 0 0 0 0 0
0 1 -2 1 0 0 0 0 0 0
0 0 1 -2 1 0 0 0 0 0
0 0 0 1 -2 1 0 0 0 0
0 0 0 0 1 -2 1 0 0 0
0 0 0 0 0 1 -2 1 0 0
0 0 0 0 0 0 1 -2 1 0
0 0 0 0 0 0 0 1 -2 1
0 0 0 0 0 0 0 0 1 -2
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Again, many ways...
But I suppose, if your homework assignment specifically required you to use toeplitz... Could you do this using toeplitz? Of course, and in fact, toeplitz would be the logical solution, and even arguably the best.
First, the line you wrote has a missing closing bracket. But more importanty, what is the first column of your desired matrix?
[-2 1 0 0 0 0 0 0 0 0]'
ans =
-2
1
0
0
0
0
0
0
0
0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
You left out the 1 there in what you wrote. You did put it in as the first row, so I'm not sure why you skipped the 1 in the first column. Fixing that, we see:
Mat = toeplitz([-2,1,zeros(1,n-2)],[-2,1,zeros(1,n-2)])
Mat =
-2 1 0 0 0 0 0 0 0 0
1 -2 1 0 0 0 0 0 0 0
0 1 -2 1 0 0 0 0 0 0
0 0 1 -2 1 0 0 0 0 0
0 0 0 1 -2 1 0 0 0 0
0 0 0 0 1 -2 1 0 0 0
0 0 0 0 0 1 -2 1 0 0
0 0 0 0 0 0 1 -2 1 0
0 0 0 0 0 0 0 1 -2 1
0 0 0 0 0 0 0 0 1 -2
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
So what is wrong with what you wrote? What exactly produced the message of "too many inputs"?
Anyway, always remember that if you get stuck trying to solve a problem one way, there may be alternatives. We could probably offer a zillion of them.