k = parallel.gpu.CUDAKernel('addvec.ptx','addvec.cu','add2'); % Create GPU CUDA kernel object from PTX and CU code

N = 128;
k.ThreadBlockSize = N;       % Array size: better to be multiple of 32.
in1 = ones(N,1,'gpuArray');  % A GPU array with all elements equal to one.
in2 = rand(N,1,'gpuArray');  % A GPU array with random values between 0 and 1.
result = feval(k,in1,in2);   % Run the kernel function on GPU and return the result.
disp(result)                 % Display the result.
