MATLAB: Replacing a Column vector value columnmatrixrows I have a matrix x=[1 2 3; 4 5 6; 7 8 9]. i wanted to replace 3rd column of matrix by a scalor value of 10. new matrix should look like x=[1 2 10; 4 5 10; 7 8 10] Best Answer x(:,3) = 10 Related SolutionsMATLAB: Replace column % 2D example:A = zeros(5)A(:,3) = 1% 3D example:A = zeros(3,3,3)A(:,2,:) = 1 MATLAB: Is it possible to extract the values with a vector of indices for each row without using the for statement from the matrix see sub2ind()A = [1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12]; % reference matrixb = [2; 1; 1; 3]; % index for each row that I want to extractidx = sub2ind(size(A), 1:size(A,1), b.');A(idx)Result>> A(idx)ans = 2 4 7 12 Related QuestionReplacing values in a column vector.How to ranking the values of one column in matrix and replace it without sorting of values of next column
Best Answer