MATLAB: For loop indexing and skip numbers for loopskip Hi, I need to include for loop in MATLAB to start with 2:13. But I need to start with 2,3,4 and skip 5 and again 6,7,8 and skip 9 and 10,11,12 until 13. How can I implement this is for loop? Many thanks in advance. Best Answer You can also use ix = floor((4*(1:n)+2)/3);where n is the desired length of the output. Related SolutionsMATLAB: Matrix extract without using for loop start=[1 3 4];rowSize=2;out = cell2mat(arrayfun(@(i1)A(i1,start(i1)+(0:rowSize)),(1:size(A,1))','un',0));ORstart=[1 3 4];rowSize=2;n = size(A,1);out = A(bsxfun(@plus,(bsxfun(@plus,start',0:rowSize)-1)*n,(1:n)')); MATLAB: Indexing n cell elements at a time E.g., is this the type of indexing you want?for j = 1:4:100 % Index through 1x100 cell temp = values(j:j+3); % Pick off the 4 cells for k = 1:4 % Use temp{k} here endend Related QuestionHi..i need to repeat rows and columns in matrix AHow to get different elements of a vectorRemove indexHow to efficiently (with no loops) compute the mean of each column in a matrix, taking different elements from each columnHi, I have a 300×300 array of data in the workspace as a result of running the code. This large array contains mostly -1.000000 values but also some values that are not -1.00000 that are useful to me. How to pick out these values from the array?Tnx
Best Answer