tomwalters@0: % tool tomwalters@0: % tomwalters@0: % INPUT VALUES: tomwalters@0: % tomwalters@0: % RETURN VALUE: tomwalters@0: % tomwalters@0: % tomwalters@0: % (c) 2003-2008, University of Cambridge, Medical Research Council tomwalters@0: % Maintained by Tom Walters (tcw24@cam.ac.uk), written by Stefan Bleeck (stefan@bleeck.de) tomwalters@0: % http://www.pdn.cam.ac.uk/cnbh/aim2006 tomwalters@0: % $Date: 2008-06-10 18:00:16 +0100 (Tue, 10 Jun 2008) $ tomwalters@0: % $Revision: 585 $ tomwalters@0: tomwalters@0: function ret=sortstruct(str,topic,nr_second_dimension) tomwalters@0: % sorts the structure str by the values in "topic" tomwalters@0: % if topic is twodimensional, then "nr_second_dimension" gives the chosen tomwalters@0: % number tomwalters@0: tomwalters@0: tomwalters@0: if nargin < 3 tomwalters@0: nr=size(str,2); tomwalters@0: for i=1:nr tomwalters@0: sortcount(i)=eval(sprintf('str{%d}.%s',i,topic)); tomwalters@0: end tomwalters@0: for i=1:nr tomwalters@0: [ismax,womax]=max(sortcount); tomwalters@0: ret{i}=str{womax}; tomwalters@0: sortcount(womax)=-inf; % den möchte ich nicht mehr sehen! tomwalters@0: end tomwalters@0: else tomwalters@0: nr=size(str,2); tomwalters@0: for i=1:nr tomwalters@0: sortcount(i)=eval(sprintf('str(%d).%s(%d)',i,topic,nr_second_dimension)); tomwalters@0: end tomwalters@0: for i=1:nr tomwalters@0: [ismax,womax]=max(sortcount); tomwalters@0: ret(i)=str(womax); tomwalters@0: sortcount(womax)=-inf; % den möchte ich nicht mehr sehen! tomwalters@0: end tomwalters@0: end