MATLAB Fcn not yet supported by Simulink coder
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am using "MATLAB Fcn " module in Simulink. But when I am trying to build my code it gives me an error message that ""MATLAB Fcn" is not yet supported by Simulink Coder". The code is given as follows:
function yd=roll(rollangr,vd,t)
persistent N1;
x2=rollangr;
e2=x2-vd;
N1=[N1;e2];
But the code N1=[N1;e2]; is impassability. Can you guide me how to fix this error. Thank you very much.
2 Kommentare
Antworten (1)
Walter Roberson
am 20 Nov. 2017
Your N1 is going to get larger every time roll() is called, by a size that is not obvious in the code 9since your inputs might be vectors or arrays.)
Simulink does not allow variables to grow to indefinite size in code generation, at least not without you having specifically turned on dynamic memory allocation for the variable.
If you need that variable to keep growing, then you should be using coder.varsize to signal the size, and you should probably be taking steps to place a maximum size on the variable, such as
if size(N1, 1) >= 200
N1(1:199,:) = N1(end-199:end,:);
N1(200,:) = e2;
N1(201:end,:) = [];
else
N1(end+1,:) = e2;
end
On the other hand, as you are not using N1 for further computation, and since your function has no way to output N1, why are you bothering to set N1 at all?
11 Kommentare
Walter Roberson
am 21 Nov. 2017
I am not sure. You could try changing
if a == 1
N1 = zeros(160,1);
end
to
if isempty(N1)
N1 = zeros(160,1);
end
Siehe auch
Kategorien
Mehr zu 执行速度 finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!