comparison sortd.m @ 0:48b6fb693025

Initial commit.
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 17 Sep 2015 10:12:50 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:48b6fb693025
1 % Sorts x with respect to the function d
2 % d is a function that accepts an element of x and returns a scalar.
3 function y = sortd(d,x)
4 v = [];
5 for i = 1:length(x)
6 v(i) = d(x(i));
7 end
8
9 [~,I] = sort(v);
10 y = x(I);
11 end