MATLAB Answers


coder.extrinsic size mismatch

Asked by Emiliano Rosso on 1 Jun 2016
Latest activity Commented on by Emiliano Rosso on 1 Jun 2016
I use in a function:
inputstemp size is (100,33,2000);
This 2 lines works very well in Matlab code but when I try to compile mex file using :
compiler return this error:
"MATLAB expression 'nanstd' is not of the correct size: expected [100x2000] found [100x1x2000]."
What's wrong?
I use "codegen" in this modality:
cfg.ResponsivenessChecks = false;
cfg.ExtrinsicCalls = true;
cfg.IntegrityChecks = false;
cfg.SaturateOnIntegerOverflow = false;
codegen -config cfg OPTIM2_GeneticPattern -args {zeros(100,82,'double')};
I want to import nanstd & nanmean in a mex file but size of imputstemp is not recognized well and it return an error.


Sign in to comment.

1 Answer

Answer by Walter Roberson
on 1 Jun 2016
 Accepted Answer

You are taking nanstd() of a 3D array along the second dimension. The result is going to have a full first and third dimension and a second dimension of 1, but you are expecting the second dimension to have vanished. You should either be assigning to a variable that has a second dimension of 1, or you should be using squeeze(), or you should permute(inputstemp, [1 3 2]) and nanmean along the third dimension so that it will be the trailing dimension that will vanish.

  1 Comment

thank you so much I successfully solved!

Sign in to comment.