I am trying to create a tri-diagonal matrix with ones and a diagonal that changes according to a function.

Right now I have

z=zeros(99,1); z(1)=25; z(2)=1; A=toeplitz(z)

where the 25 is just a placeholder number for now. The value of 25 is what I want to change according the following for loop of

z = (2 + (0.1)*(h)^2)/.01

This gives 99 values from 200 to 210, but they change by a non-constant amount.

One thought I had was to put these output into a vector and then just use the diag() command and add the other diag(1)'s to it. But when I use the code

it only returns the last value of 210 to me, not all 99 different values.

How would I go about changing all of the diagonals to be the number output by the for loop? Preferably, I would also like the a_11 and a_99 to also just be 1 instead of the values of the function, if possible.

Thank you very much.