function answer = fixcube4 %this function is called 'fix4cube3d' %returns some variable called 'answer' f = [-50,50]; %defines matrix 'f' with elements -50 and 50 M = []; %defines M as an empty matrix for i = 1:2; for j = 1:2; for k = 1:2; M = [M; f(i), f(j), f(k)]; %displays 3x8 matrix with all possible %combinations of -50 and 50 end end end Mat = []; %Declaring new matrix for future reference for i = 1:size(M,1) for x = (M(i,1):M(i,1)+3) for y = (M(i,2):M(i,2)+3) for z = (M(i,3):M(i,3)+3) %cyclces through to points incorporating %one fixed point per fixed cube Mat = [Mat; x y z]; %arranges data in a matrix end end end end answer = Mat;