coder.extrinsic size mismatch

6 次查看(过去 30 天)
I use in a function:
STDinputs(nset1,nimp1)=nanstd(inputstemp,0,2);
AVinputs(nset1,nimp1)=nanmean(inputstemp,2);
inputstemp size is (100,33,2000);
nset1=1:100;
nimp1=1:2000;
This 2 lines works very well in Matlab code but when I try to compile mex file using :
coder.extrinsic('nanstd','nanmean');
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=coder.config;
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.

采纳的回答

Walter Roberson
Walter Roberson 2016-6-1
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 个评论
Emiliano Rosso
Emiliano Rosso 2016-6-1
thank you so much I successfully solved!
STDinputs(nset1,nimp1)=squeeze(nanstd(inputstemp,0,2));
AVinputs(nset1,nimp1)=squeeze(nanmean(inputstemp,2));

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Algorithm Acceleration 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by