thank you for helping. actually it is easy to implement if I use a(1) in stead of a(0).I just wanted to learn that. So,ıf there is no way to do, I will do using a(1).
Not sure if this is what you meant, but the code below will do EXACTLY what you said. This code willreplace the nth element only, with the sum of the elements from 1 to n, and leave the other elements of A unchanged. n is 100. If that's not what you meant, then please be specific.
% Define sample data of length 120.
A = randi(9, 1, 120)
n = 100; % or whatever element you want to stop at.
fprintf('A(%d) initially equals %d\n', n, A(n));
% Replace the nth element only, with the sum of the elements from 1 to n.
% Leave the other elements of A unchanged!
A(n) = sum(A(1:n))
fprintf('but now A(%d) equals %d\n', n, A(n));
Note: because MATLAB starts at 1 but you started at 0, you may have to adjust n or else adjust the sum:
A(n) = sum(A(1:n+1)); % n=8 is the 9th element if you consider A starting at 0