Technically, yes you can (given that you've installed CUDA) combine both. However, whether or not you get anything useful out of it, is another matter.
For starters see here, and try to locate your current GPU configuration:
Error tells us MATLAB cannot find any GPU on the machine, in that case follow the instructions to setup the GPU.
Afterwards, you can start working with gpu arrays:
mygpuArray = gpuArray(1:20);
If you want to generalize your function to check if GPU available (as you mentioned), you can implement something like: