Prev: Text File With Header
Next: FTP problem accessing NASA
From: SM on 13 May 2010 11:43 I could debug the program, and apparently it's working correctly. Here is a simple example A=[1 2 4 3 6 5]; c=sort(A); c_old=c for j=1:5 B=A+(j-1)/j; c=sort(unique([c_old B])); c_old=c; end % output for j=5 is: c=[1.0000 1.5000 1.6667 1.7500 1.8000 2.0000 2.5000 2.6667 2.7500 2.8000 3.0000 3.5000 3.6667 3.7500 3.8000 4.0000 4.5000 4.6667 4.7500 4.8000 5.0000 5.5000 5.6667 5.7500 5.8000 6.0000 6.5000 6.6667 6.7500 6.8000]
From: Matt Fig on 13 May 2010 12:50
Sorting the output of UNIQUE is superfluous. Also, this should be faster: V = (0:(N-1))./(1:N); c2 = repmat(sort(A),length(V),1); c2 = reshape(bsxfun(@plus,c2,V'),1,[]); |