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

42 vues (au cours des 30 derniers jours)
kajal shah
kajal shah le 6 Fév 2017
Réponse apportée : cr le 6 Fév 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

Réponses (1)

cr
cr le 6 Fév 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.

Catégories

En savoir plus sur Simulink dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by