MATLAB: How to add numbers to indexes indexing I have an array of indexes eg [2 3 4 5 1 6 7]. I have an array of numbers [1 4 6 8 3 7 9]. I would like to assign the numbers according to the indexes in one command. Is it possible? Best Answer idx=[2 3 4 5 1 6 7] numb=[1 4 6 8 3 7 9] numb(idx) Related SolutionsMATLAB: Random numbers idx = [1,2,4,7,8];out = zeros(10,1);out(idx)=rand(numel(idx),1); MATLAB: Divide an array in n different arrays V = [1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 3 3 3 3 3 3 3 5 5 5 5 5 5 5 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 1 1 1 1 1 6 6 6 6 6 6 6]A = [1 3 46 5 20 8 00 9 0][~,c,a] = find(A);[~,i] = ismember(V,a);g = c(i);d = find([true; diff(g); true]);c = mat2cell(V,1,diff(d));c{:} Related QuestionIndexing complex numbersHelp running Matlab scriptRetrun largest numbersIs it possible to extract the values with a vector of indices for each row without using the for statement from the matrixFor loop indexing and skip numbers
Best Answer