samer@4: function X=nthret(I,F,varargin) samer@4: % nthret - Evaluate function and return Nth return value. samer@4: % samer@4: % Usage: samer@4: % samer@4: % if F is a function that returns M >= I values, then samer@4: % X = nthret(N,F,...) samer@4: % evaluates [Z{1:N}]=F(...) samer@4: % and returns Z{N}. samer@4: samer@4: Z=cell(I,1); samer@4: [Z{:}]=F(varargin{:}); samer@4: X=Z{I};