MATLAB: How to create a vector of this output for loopvector Hi! Can anyone tell me how to do this in matlab? I've tried using 3 for loops but I am getting the wrong answer. My range is from -2 to 2. Here is what I want to get: … and so on and so forth. Thanks a lot! Best Answer Try this: [X,Y,Z] = ndgrid(-2:2);Out = [Z(:),Y(:),X(:)]producing: Out = -2 -2 -2 -2 -2 -1 -2 -2 0 -2 -2 1 -2 -2 2 -2 -1 -2 -2 -1 -1 -2 -1 0 -2 -1 1 -2 -1 2 -2 0 -2 -2 0 -1 -2 0 0 -2 0 1 -2 0 2 etc. Related SolutionsMATLAB: How to create permutations of multisets Try thisx = [0 0 1 1 2 2];M = unique(perms(x), 'rows'); MATLAB: What is the output length of x is 3. When you subtract 1 from a numeric vector you do not change the length so length((x) - 1) is the same length(x) which is 3. So your for loop isfor n=4:3Which will not execute at all. Related QuestionProblem when trying to solve a rotation matrix with symbolic elements: (Master thesis)Replacement of groups of neighbor numbers giving priority to a row-wise check
Best Answer