MATLAB: Swap the values in matrix swapping Hello, I have a matrix [2 3 4 5 6 7] a=2 b=3 i want to swap two values ans is [3 2 4 5 6 7] Best Answer InMtx=[2 3 4 5 6 3 3 4 2];a=2;b=3;Twos=InMtx==a;Threes=InMtx==b;InMtx(Twos)=b;InMtx(Threes)=a; Related SolutionsMATLAB: Combining matrices, adding two matrices in into a bigger one. Kg(3:6,3:6)=Kg(3:6,3:6)+Ke2 MATLAB: From a=[1 2 3 4] to b=[1 1 2 2 3 3 4 4] b = repelem(a,2) Related QuestionHow to create a matrix which is difference (like in sets) of antoher 2 matrixHow to extend arrayGenerate random matrix ‘r’ of size 3 by 4 with number varying between -4 and 6Delete duplicated row in a matrix
Best Answer