function canUse = canUseGPU() %CANUSEGPU Check if a compatible GPU is available for parallel computing % Returns true if MATLAB Parallel Computing Toolbox is available and % a CUDA-capable GPU is detected. canUse = false; % Check if Parallel Computing Toolbox is installed if ~license('test', 'Distrib_Computing_Toolbox') return; end % Check for GPU device try gpu = gpuDevice(); canUse = gpu.DeviceSupported; catch canUse = false; end end