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

42 Ansichten (letzte 30 Tage)
kajal shah
kajal shah am 6 Feb. 2017
Beantwortet: cr am 6 Feb. 2017
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

Antworten (1)

cr
cr am 6 Feb. 2017
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.

Kategorien

Mehr zu Simulink finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by