Size mismatch for MATLAB expression 'unique'. Expected = 1x1 Actual = 8x1

43 次查看(过去 30 天)
I am working on embedded function matlab (simulink), I want to find unique values of matrix pbatt_const_Pb_filter. The body of my code is
coder.extrinsic('unique');
A=pbatt_const_Pb_filter';
pbatt_filt=unique(A(:,1));
and have declared variable as below
Pbatt_filtered_int=zeros(1,100); coder.varsize('Pbatt_filtered_int'); pbatt_filt=Pbatt_filtered_int;
Everytime the error comes'Size mismatch for MATLAB expression 'unique'. Expected = 1x1 Actual = 8x1 "
and when I flip the declaration of variable to Pbatt_filtered_int=zeros(100,1; the error is Call to MATLAB function aborted: A variable-size array input to FIND in MATLAB Code Generation must not reduce to a row vector at run time.
Please suggest

回答(1 个)

cr
cr 2017-2-6
Size mismatch error is a result of unmatched dimensions in signals. The block being driven by embedded function block is expecting a scalar input but the unique function is producing a vector possibly because there a multiple unique elements in the input matrix.

类别

Help CenterFile Exchange 中查找有关 Simulink 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by