MATLAB: Mink and maxk functions

maxkmink

I'm using MATLAB R2017a. While trying to use "mink" and "maxk" functions, the MATLAB responds "Undefined function or variable 'maxk'." These two functions were introduced in R2017b. Is it possible to use these functions with R2017a? if yes, then how?

Best Answer

One approach would be writing your own function:
function y=mink(A,k)
A=sort(unique(A));
y=A(1:k);
end
Call this function from command line as follows
A=1:10;
mink(A,3)
and the first three smallest elements will be displayed.