My (really inelegant) solution to this is to create the result array outside the function, and pass that in as an argument, then explicitly write out the for-loops.
Eg:
function Y = Foo(X,Y)
% Assert sizes here so codegen knows
for i=1:size(X,1)
for j=1:size(X,2)
Y(i,j) = 20*log10(abs(X(i,j)));
end
end
end
Is there a better way of doing this?