MATLAB: Sort cell array in descending order based on 2nd column MATLAB i have cell array and want to sort it based on 2nd column . i have tried this [~,idx] = sort([AA{:,2}]); idx([1:2:end,2:2:end]) = idx; B = AA(idx,:); but 2nd column in not in descending order . Best Answer The [65 x 2] cell array in your mat file is named "A1".[~, idx] = sort([A1{:,2}], 'descend'); A1_descendingOrder = A1(idx,:) Related SolutionsMATLAB: Boxplot with descending median Use the sort index to change the order of columns in your data.% Create demo datarng('default')data = rand(8376, 35).*randi(100,1,35); % Compute median of each column med = median(data); % Sort the columns of data by descending median order[~, sortIdx] = sort(med,'descend'); dataDescend = data(:,sortIdx); % Plot the resultsboxplot(dataDescend)If you want to label the orginal column order, set(gca, 'XTick', 1:numel(med), 'XTickLabel', sortIdx)xlabel('Original column order') MATLAB: Taking a descend interval Inserttau = n+1-t;then raise 1/800 to the power tau. Related QuestionSort a cell array based on the number of rows in each cellSorting Vectors descending orderSorting cell array containing alphanumeric textSorting in descending order by row
Best Answer