MATLAB: Find a vector in a big vector find statement in matlab hi! how could i write this: %index=[find(a=2);find(a=4);find(a=6);find(a=8)....find(a=20)] in a compact manner? thank you Best Answer vals = (2:2:20)';your_mat = cell2mat(arrayfun(@(x) {find(a==x)},vals,'uniformoutput',false));And if you don't care about the order: vals = (2:2:20)'; [ia ib] = ismember(a,vals); Related SolutionsMATLAB: Find index of last 5 largest values in cell array This works:[as,idx] = sort(cell2mat(a),'descend');result = idx(1:5); MATLAB: How to create a matrix from existing matrix a = [0.25 0.20 0.15 0.20 0.1];your_mat = cell2mat(arrayfun(@(x,y) ((x:x:1)'+y)',a,0:numel(a)-1,'uniformoutput',false));your_mat = [0;your_mat']; Related QuestionHow to generate a matrix of 1 by L dimentions contains complex data from real and imaginary componentsHow to find unique lines in cell arraysHow to find index of duplicate values in a matrixDeleting multiple rows in a matrix
Best Answer