"Can anyone please explain to me what im doing wrong and how to fix it."
Your first code does not store/allocate/sum the output in any way, so you simply discard the output of each loop iteration, keeping only the results of the last iteration.
"This code keeps saying there are different elements between right side and left side."
Your second code works without error on the first and second iterations, but then on the third iteration you forgot to consider that sc will now have size 1x2, to which you add some scalars, thus also giving an output of size 1x2. However you then try to allocate these two elements into one element on the LHS:
One element of a numeric array contains one value: it is an error to try an store multiple elements/values into one element of a numeric array.
You do not describe your algorithm at all, but a few small changes allows your code to run and store its output values (you need to check the algorithm yourself):
I = 800/365*1.5;
O = 400*17000/1000000;
N = 3;
sc = nan(1,N);
sc(1) = 8;
for d = 2:N
sc(d) = sc(d-1)+I-O;
8 4.4877 0.97534