MATLAB: How to change plot from Descending to Ascending arraygraphMATLABmatrixmatrix arrayplotplottingsubplot If I have plot(k,gpa,'r+:',finalArray2,finalArray1); which forms a descending plot, what can I change to make it an ascending plot? Best Answer Maybe something like using sort() to sort your data,[gpa, sortOrder] = sort(gpa, 'descend');k = k(sortOrder); % Sort k the same way.or setting the xdirection to reverse:ax = gcaax.YDir = 'reverse'; Related SolutionsMATLAB: Rank matrix elements in descending order Why not just use the sort() function?m=magic(5);% Sort columns in descending order.sorted_m = sort(m, 'descend') MATLAB: 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') Related QuestionSort a one dimensional array ascend and descendChanging horizontal axis to descending orderDescending Axis Meshgrid PlottingHow to arrenge the calculated distances in ascending orderHow to find ascending and descending of hysteresis loopSorting Vectors descending order
Best Answer