% RequireFEXpackageExample2- script demonstrating how 
% the function 'requireFEXPackage' can be used to add (on demand) 
% other FEX submission on which your submission relies. 
% This example uses the ''try-catch'' command.
% 
% (C) Igor Podlubny, 2011

syms x
RosenbrockBananaFunction = @(x) (1-x(1)).^2+100*(x(2)-x(1).^2).^2;
try 
   % if function 'fminsearchbnd' already exists in your MATLAB
   % installation, just use it:
   x = fminsearchbnd(RosenbrockBananaFunction,[3 3])
catch 
   % if function 'fminsearchbnd' is not present in your MATLAB
   % installation, first get the package 8277 (to which it belongs) 
   % from the MATLAB Central File Exchange (FEX)
   P = requireFEXpackage(8277);  % fminsearchbnd is part of 8277
   % and then use that function:
   x = fminsearchbnd(RosenbrockBananaFunction,[3 3])
end



