The ultimate goal is having the distance_result matrix to be filled with y rows and each row to be filled with x data (array). The first while loop generates the distance_result matrix and the second while loop takes care of the calculations for the distance array.

The problem is that the distance_result matrix has y rows that are all the same. For some reason the distance array is not changing with every iteration. Since y=y+1, then I expect the distance(x) to be changed for every new while loop for y.

Thank you!

`clcclearx=1;y=1;p=1;while (y<=1000) %y-axis`

while (x<=1000) %x-axis

distance(x)=5*p*y*x; x=x+1; p=p+1; end distance_result(y,:)=distance; %a matrix storing all x-axis and y-axis outputs

y=y+1; end

## Best Answer