matlab - Calling generic functions on rows of a matrix -
i'd compute kernel matrices efficiently generic kernel functions in matlab. means need compute k(x,y)
every row x
of x
, every row y
of y
. here matlab code computes i'd like, rather slow,
function k=compute_kernel( k_func, x, y ) m = size(x,1); n = size(y,1); k = zeros(m,n); = 1:m j = 1:n k(i,j) = k_func(x(i,:)', y(j,:)'); end end end
is there other approach problem, e.g. bsxfun
variant calls function on every row taken x
, y
?
have tired pdist2
custom distance function?
p.s. best not utilize i
, j
variables in matlab
matlab machine-learning bsxfun
No comments:
Post a Comment