The function fminlbfgs gives a BSD license implementation of L-BFGS (so appropriate use of this in commercial applications is okay). Here, we describe some details.
It has an interface that is very similar to minFunc, and only very minor changes are required to get it to work.
Specifically, the "options" variable needs to be specified differently (fminlbfgs uses different names for the parameters). Here's a parameter set that will work for fminlbfgs:
options.HessUpdate = 'lbfgs'; options.MaxIter = 400; options.Display = 'iter'; options.GradObj = 'on';
After setting options as above, the function call to run minFunc/fminlbfgs is exactly the same. Here's an example that works:
% Run fminlbfgs [opttheta, loss] = fminlbfgs( @(p) sparseAutoencoderLoss(p, ... visibleSize, hiddenSize, ... lambda, targetActivation, ... beta, patches), ... theta, options);