How to fit curves in Simulink and still generate the code?
I have a model of a sensor in Simulink, that returns vectors "Pos_x" and "Pos_y". Each vector has size of 20x1, whose values change every one step time (1ms).
I am trying to calculate the coeffecients of the 3rd degree Polynomial y(x) = p1*x^3 + p2*x^2 + p3*x + p4 in Simulink, that fits the data.
I did not find any block in simulink that calculates the coeffecients, so I used a simple Matlab function
function [p1, p2, p3, p4] = fcn(x,y)
f = fit(x', y', 'Poly3');
p1 = f.p1;
p2 = f.p2;
p3 = f.p3;
p4 = f.p4;
but I get the error: Function 'fit' not supported for code generation.
1- so back to my qustion, How to fit curves in Simulink and still generate the code?
2- I am also open to any other suggestion