sorting - Sort the first N elements of a vector in MATLAB -


i sort first n elements of vector has more elements. example:

a = [3 2 5 1 8 9 2 1 9]; 

if n = 5, output should be:

b = [1 2 3 5 8 9 2 1 9]; 

i have vector of indices v, b = a(v).

how can this?

[b, v] = sort(a(1:n)); b = [b, a(n+1:end)];    % sorted vector v = [v, n+1:numel(a)];  % index vector 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -