0

I'm doing a project in school and I need to evaluate the roots of a 7th order polynomial during a Simulink simulation. For that, I've decided to use the "roots" function but it seems that Simulink doesn't like this function - when running the simulation this error appears:

"Data radius_new is inferred as a variable size matrix, while its properties in the Model Explorer specify its size as inherited or fixed. Please check the 'Variable Size' check box and specify the upper bounds in the size field."

The code I have inside my function block is the following:

p = [A*10.^5 B_3*10.^5 B*10.^5 0 E 0 C*10.^5 0 D*10.^5];
R = roots(p);
radius_new = R(real(R)>=0 & imag(R) == 0);

where A, B...are defined constants changing with time.

I have run this on a normal script and it gives the value I need. For some reason, on Simulink, that does not happen.

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
  • Have you tried doing what the message asks you to do? There might be 0 to 7 roots so a vector holding the roots would indeet be of variable size. – Daniel Mar 10 '20 at 17:43
  • Hi Daniel, thank you for your help. I have tried but another error pops up. Basically, the error asks me to give the variable an "upper-bound" but I actually don't know what that means. I think the problem is truly related to the function roots. I ha – vaskinz Mar 10 '20 at 19:51
  • What error message? – Daniel Mar 10 '20 at 19:52
  • When I check the "Variable Size" box, they ask me for an upper-bound. I put 1, as I know it is a simple scalar and the next error pops up: Size computation for 'V_balloon' (#25) failed. MATLAB Function Block and Stateflow do not support Variable Sizes for scalar signals. – vaskinz Mar 10 '20 at 19:58
  • ...difficult to give any advice without knowing what `V_balloon` is. – Daniel Mar 10 '20 at 21:11
  • Hi Daniel! It doesn't matter what V_balloon, it is just a variable coming from the function. Perhaps I could sent you my project for you to help me? – vaskinz Mar 21 '20 at 14:38

0 Answers0