How to set Matlab function block output as fixed (non-tunable) variable
Ältere Kommentare anzeigen
I have been trying to clean some dust of my Simulink models shelves and encounter the following hurdle:
I'm using a Matlab function simulink block to output 2 scalar numbers vectIndx and tableNum. While trying to run the simulation (which run perfectly well with Matlab 2016B), I'm getting the follwing error:
'vectIndx' is inferred as a variable-size matrix, but its size is specified as inherited or fixed. Verify 'vectIndx' is defined in terms of non-tunable parameters, or select the 'Variable Size' check box and specify the upper bounds in the Size box.
Component:MATLAB Function | Category:Coder error
I have tried to add
vectIndx=zeros(1)
at the top of my funciton code but that didn't work either.
I have run the same block while disabling the function output variables via dubg mode and made sure these outputs holds scalar numbers.
I have read the following post: https://www.mathworks.com/matlabcentral/answers/513980-why-are-my-matlab-function-block-arguments-being-inferred-as-variable-size but didn't quite get how to set the outputs as non-tunable.
Please see my code bellow:
function [vectIndx,tableNum] = fcn(mabc,Uabc,delt,vDrop,vectNum)
vectIndx = zeros(1,1);
tableNum = zeros(1,1);
%#codegen
Uabc = [Uabc; 0]; % last entries for zero voltage drop
delt = delt';
i = find(vectNum == [100 10 1]*mabc); % current vector representation
tableNum = i(1);
regMtrx = -1*Uabc(abs(vDrop(:,:,i))).*sign(vDrop(:,:,i)).*repmat(delt,size(vDrop,1),1);
[~, vectIndx] = max(sum(sign(regMtrx),2));
Cheers!
ML
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Array and Matrix Mathematics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!