I am making a script-m file to produce results of a formula in a Matrix output. Code (Text): function s = calc(a, b) i = [-a: 1: a]; j = [-b: 1: b]; k = i.^2 + j.*i; A = [i' j' k'] disp('i j k'), disp(A) But, it does not consider all combination. How can I make it stop at a 'i' value so all 'j' values can be matched to that and solved for 'k' before proceeding. In my code, it just does one round of 'i' and 'j' values.