I have a MATLAB function block in Simulink and I'm using it to generate a spline function but every time I try to generate a code using PLC Coder out of it, I keep getting this error:
The extrinsic function 'function_trial' is not available for standalone code generation. It must be eliminated for stand-alone code to be generated. It could not be eliminated because its outputs appear to influence the calling function. Fix this error by not using 'function_trial' or by ensuring that its outputs are unused.
and i tried to put all my code in one function but it didn't work.
here is my code:
%
function y2 = function_trial(points,w)r2=(([0:2:360]/180)*pi);points=sin(r2);m=[r2' points'];t = (0:180);points = m;x=points(:,1);y=points(:,2);tq = 0:0.1:180;slope0 = 0;slopeF = 0;xq = spline(t,[slope0; x; slopeF],tq);yq = spline(t,[slope0; y; slopeF],tq);values = csaps( xq, yq);y2=fnval(values, w);
main block function:
%function out = fcn(points, w)coder.extrinsic('function_trial');out=0;out=function_trial(points , w);
any Idea how can I solve this issue?
Thank you!
Best Answer
I've achieved my goal by building a curve between 3 points and finding out the value of an ordinate on it. I wrote a function in the "Matlab function" simulink block and it works!
code: