Some of my guesses would have been correct.
Your first equation then has a delta function at k==0. And I'll assume the last term is actually C_1(k).
120000(k+1)C_1(k+1) = 1000delta(k) + 18000(C_2(k) - C_1(k)) - 1200C_1
I'll write the code, as I would want to write it. First, I'll preallocate the vectors. Growing vectors ensures that your code will run slowly. Better yet, is to store all of these vectors in one 2-dimensional array. By doing that, then we can implement the recurrence as an even simpler operation.
I will also point out there are problems in your other equations. For example in the second equation, there is a missing right parenthesis. I guessed where that went, but I may be wrong.
I also did NOT cancel the coefficients you have written, as you could easily make a mistake when doing so.
kmax = 11;
c = zeros(4,kmax);
delta = @(k) [double(k==0);0;0;0];
M = [[-18000-1200, 18000, 0, 0]; ...
[18000, -18000-120000-180000-10000-10800, 120000*0.1, 180000]; ...
[0, 120000, -120000*0.1-18, 0]; ...
[0, 180000, 0, -180000-100000]];
for kind = 1:kmax-1
k = kind - 1;
c(:,kind+1) = (1000*delta(k) + M*c(:,kind))./([120000;1080000;1800;1080000]*(k+1));
end
You should see that delta now works as a simple function that will impact only c1, and then only when k==0.
delta(0)
ans =
1
0
0
0
delta(1)
ans =
0
0
0
0
When I run the above code, I find myself not entirely confident this is correct, but that is because I am not confident that your equations were written correctly. I have transcribed them quite carefully as coefficients of the matrix M. In fact, I have checked several times.
c =
Columns 1 through 9
0 0.0083333 -0.00066667 3.9028e-05 -1.9723e-06 2.2721e-07 -1.6865e-07 1.6036e-07 -1.36e-07
0 0 6.9444e-05 -1.0965e-05 5.47e-06 -6.5036e-06 7.3035e-06 -7.0823e-06 6.0119e-06
0 0 0 0.0015432 -0.0027586 0.0037566 -0.0042526 0.0041257 -0.0035022
0 0 0 3.858e-06 -7.0695e-07 2.1899e-07 -1.9012e-07 1.8093e-07 -1.5341e-07
Columns 10 through 11
1.0262e-07 -6.9688e-08
-4.5364e-06 3.0807e-06
0.0026427 -0.0017947
1.1575e-07 -7.8608e-08
The numbers you claim to be "true" appear to be inconsistent with the equations you have written. But that may just mean your equations were still written improperly.