MATLAB: Double for loop with changing start point at second loop. need help, wrong output.

changing start pointdoublefor loopwrong output

i have simplified my matlab script to this:
clear all
clear variables
clc
n = 10
for N1 = 1:1:(n-1)
C = N1;
for N2 = (N1+1):1:n
D = N2;
F = C+D;
X1(:,N2) = F;
end
X2 = X1.';
X3(:,N1) =X2;
end
X3
Results are:
X3 =
0 0 0 0 0 0 0 0 0
3 3 3 3 3 3 3 3 3
4 5 5 5 5 5 5 5 5
5 6 7 7 7 7 7 7 7
6 7 8 9 9 9 9 9 9
7 8 9 10 11 11 11 11 11
8 9 10 11 12 13 13 13 13
9 10 11 12 13 14 15 15 15
10 11 12 13 14 15 16 17 17
11 12 13 14 15 16 17 18 19
so the problem here is that the output of matrix X3 is wrong. the reason why it is wrong is because of the second for loop. when the start point changes of the second for loop it should have a 0 value for all the points before the start point. but in this script when N1=5 and N2 = 6 to 10 we obtain an output for N2 = 2-5 also from the previously values. The second for loop do not reset values for each loop. how do i fix this?? the results should be like this matrix:
X3 =
0 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0
4 5 0 0 0 0 0 0 0
5 6 7 0 0 0 0 0 0
6 7 8 9 0 0 0 0 0
7 8 9 10 11 0 0 0 0
8 9 10 11 12 13 0 0 0
9 10 11 12 13 14 15 0 0
10 11 12 13 14 15 16 17 0
11 12 13 14 15 16 17 18 19

Best Answer

n = 10;
result = zeros(n,n-1);
for N1=1:1:(n-1)
for N2=(N1+1):1:n
result(N2,N1) = N2+N1;
end
end