MATLAB: How to extract all values in a row of an array without the its maximum value max/min ex a= 1 3 6 56 7 1 95 3 9 10the extracted row will be 5 3 9 Best Answer >> a = [1,3,6,5;6,7,1,9;5,3,9,10]a = 1 3 6 5 6 7 1 9 5 3 9 10>> [r,c] = find(a==max(a(:))); % identify row and column of max value.>> b = a(r,[1:c-1,c+1:end]) % extract row, excluding max value.b = 5 3 9 Related SolutionsMATLAB: 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 MATLAB: How to find a subset matrix in the main matrix and build a new matrix I assume that the order of the rows in C don't matter:[~,~, ib] = intersect(A, B(:, 1:5), 'rows'); %find rows of A in Bids = B(ib, 6); %get the ID of those rowsC = B(ismember(B(:, 6), ids), :); %get rows whose ID match Related QuestionExtract one element from row vectorsHow to filter rows with respect to specific entrySplitting vectors into cell array in a loop
Best Answer