MATLAB: How to create a matrix of coordinates coordinatesmatrix manipulation I want create a matrix like this for any input, in this example input is "3". a = (3,1) (3,2) (3,3) (2,1) (2,2) (2,3) (1,1) (1,2) (1,3) But i dont know how to do Best Answer Hi,Try something like this.n = input('Enter value')for i = 1:2 for j = 1:n for k = 1:n if i == 1 a(i,j,k) = n-j+1; elseif i == 2 a(i,j,k) = k end end endend Related SolutionsMATLAB: Matrix Conversion use reshape:a = [1 2 3 4];reshape(a,2,2).'You may find also useful Resizing and Reshaping Matrices MATLAB: How to return the values of a loop You are computing k once for each value of i and overwriting it. If I understand what you want, try: i = 1:5; j = 0:5; k = zeros(numel(i),numel(j)); for a = 1:numel(i) for b = 1:numel(j) k(a,b) = i(a)^2 + i(a)*j(b) + j(b)^2; end end display(k) Related QuestionCalculating each elements of matrixsHow to update matrix values using algorithm based on positionNeed help in creating matrix…..pleaseHow can i correct this error
Best Answer