MATLAB: Change even column values only matrix I create 20*20 2D array of all ones. And then I want to change even columns to minus one. How can I change with builtin function? Best Answer A = ones(20);A(:,mod(1:20, 2) == 0) = -1; Related SolutionsMATLAB: Change specific col and row in a matrix A=[20 40 60 70; 10 20 30 40; 60 50 20 10] ;r = [2 3 1] ;c = [2 2 1] ;B = A ;% Method 1 , use loopfor i = 1:length(r) A(r(i),c(i)) = 5 ;end% Method 2, use indicesidx = sub2ind(size(A),r,c) ;B(idx) = 5 ; MATLAB: Selecting even rows A - your matrixA = randi(23,14,6)out = A(2:2:end,:) Related QuestionGrouping values of 3 columnsHow to change the place of two numbers randomnly in a rowWorking with even rowsHow to get odd rows and columns,even rows and columnsCount even elements vectorCreating combinations of 3 vectors
Best Answer