GetNeighborhood function for 3D cells structure in MATLAB
I think the biggest gain in efficiency you can get is to  not use a cell array. Each element of a cell array is an array. Each array has a header data structure that takes up 104 bytes (if I remember that number correctly). Storing only one number in an array means that there is a memory overhead of 104/(104+8)=92%. Access is also slower because of the double indirection. To store individual numbers you should always use a numeric array.
This code:
if X + x &lt; 1
   xLocation = 1;
elseif X + x &gt; size(inputCells, 1)
   xLocation = size(inputCells, 1);
else
   xLocation = X + x;
end

has quite some redundancy. Every time you write the same expression twice, you should think about storing the result of the expression. Even if the computation is trivial and likely not to slow down your code, duplicated code still leads to maintenance issues. You could do instead:
xLocation = X + x;
maxLocation = size(inputCells, 1);
if xLocation &lt; 1
   xLocation = 1;
elseif xLocation &gt; maxLocation
   xLocation = maxLocation
end

This can be further simplified using max and min:
xLocation = X + x;
xLocation = max(xLocation, 1);
xLocation = min(xLocation, size(inputCells, 1));

You could maybe even simplify this to a single line of code, though that doesn’t improve readability:
xLocation = min(max(X + x, 1), size(inputCells, 1));

Furthermore, this code is repeated three times, so you should make it into a function you can call three times.
Once your input and output are numeric arrays, you can likely vectorize the operation, removing the loops and further simplifying the code.
clear all is not recommended. clear by itself clears the workspace, deleting all defined variables. Adding the all argument causes it to additionally remove from memory all parsed and pre-compiled functions, meaning that the next time you call those functions they’ll take longer to run. clear all is hardly ever needed, and should not be a part of your normal workflow.