MATLAB: How to augment a vector into another vector vectors augmentation v1 = [0 1 2 3], v2 = [0 1 2] the resultant v3 =[0 0;1 0;2 0;3 0;0 1;1 1;2 1;3 1;0 2;1 2;2 2;3 2] Best Answer v1 = [0 1 2 3], v2 = [0 1 2][a,b]=ndgrid(v1,v2)out=[a(:) b(:)] Related SolutionsMATLAB: Matrix Manipulation A = [1; 1; 3; 1; 2; 1; 1; 1; 3; 1; 1; 1; 1; 2; 1; 1; 1; 1; 1; 3; 1; 1; 1; 2; 1; 1; 1; 1; 1; 2; 2; 1; 1; 1; 2; 1; 1; 2; 1; 1; 1; 1; 1; 1; 3; 1; 1; 3; 2; 1; 1; 1; 1; 1; 1; 1; 2; 2; 4; 1; 1; 2; 1; 1; 1; 1; 2; 2; 1; 1; 1; 3];a1=find(A==2)-1; %find the index of the 2a2=find(A==3)-1; %find the index of the 3a2=repmat(a2,2,1) %duplicate the 3 indexesB=sort([a1;a2])'; %join and sort the solution, also transpose%I transposed B because of your B example MATLAB: Find the maximum value in different vectors and from which vector is it max_val = max([v1, v2,v3]); % or max_val = max([v1(:);v2(:);v3(:)]);v1 = v1 == max_val;v2 = v2 == max_val;v3 = v3 == max_val; Related QuestionGeneric index select, without loopsHow to shuffle two vectorsAugmented dicky-fuller with lags
Best Answer