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.
clcclearx=1;y=1;p=1;while (y<=1000) %y-axiswhile (x<=1000) %x-axisdistance(x)=5*p*y*x;x=x+1;p=p+1;enddistance_result(y,:)=distance; %a matrix storing all x-axis and y-axis outputsy=y+1;end