function isInstalled = fuzzychecktoolboxinstalled(ToolboxDir)
% Check whether an optional product is installed and its license is
% available.  Specify the product directory name as the input.

% Author(s): Rong Chen
% Copyright 1986-2011 The MathWorks, Inc. 

ProductNames = {'Control_Toolbox';
                'Fuzzy_Toolbox';
                'Identification_Toolbox';
                'MPC_Toolbox';
                'OPC_Toolbox';
                'Optimization_Toolbox';
                'Robust_Toolbox';
                'Simulink';
                'Simulink_Control_Design';
                'Simulink_Design_Optim';
                'Real-Time_Workshop';
              };
          
ProductDirs = { 'control';
                'fuzzy';
                'ident';
                'mpc';
                'opc';
                'optim';
                'robust';
                'simulink';
                'slcontrol';
                'sldo';
                'simulinkcoder';
              };

index = find(strcmpi(ToolboxDir,ProductDirs));
isInstalled = ~isempty(index) && license('test',ProductNames{index}) && ~isempty(ver(ProductDirs{index}));
