Size mismatch for MATLAB expression 'unique'. Expected = 1x1 Actual = 8x1
21 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
cr
on 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.
0 Comments
See Also
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!