MATLAB function in Simulink
显示 更早的评论
I need some help to finish my simulink model of an ESP sistem. I need to find the real roots of a 6th order polynomial in Simulink and use it for the simulation. I Made a MATLAB function block and wrote this code:
function x = fcn(A)
%#codegen
K=0.25;
P = [K -(K+1) K+1 -(K+1) K+1 -(K+1) 1-A];
r = roots(P);
real = r(imag(r)==0);
x = real(real<1.1);
A is an variable and K is an constant. x has to be just one number. After Runing the code in i get this errors in simulink:
Data 'x' is inferred as a variable size matrix, while its specified type is something else.
Error in port widths or dimensions. Invalid dimension has been specified for input 'A'.
To be honest im not sure if this will work in any way but this is my try. Ive checked the code in MATALB and it gives me what i want. Im not rly sure what these errors means. How can i make it work to get the roots of an polynomial in Simulink?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 FPGA, ASIC, and SoC Development 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!