I am trying to generate code using MATLAB Coder for the following function:
function a = test(b) %#codegen
% Test in C: if(b!=NULL)
if ~isempty(b) a = b + 2; end end
When I now compile that function test with Matlab Coder into a *.c file (I have configure the input argument 'b' to be a size of 3 double vector for example) the result is:
void test(const real_T b[3], real_T a[3]) { int32_T i6; for (i6 = 0; i6 < 3; i6++) { a[i6] = b[i6] + 2.0; } }
But I want to have something like:
void test(const real_T b[3], real_T a[3]) { int32_T i6; if(b!=NULL) { for (i6 = 0; i6 < 3; i6++) { a[i6] = b[i6] + 2.0; } } }
Is there a way to do this?
Best Answer