- #1
aspiers
- 1
- 0
Hi,
I keep running into the same problem using the embedded MATLAB blocks of simulink. Once the equations to be solved in my blocks reach a certain length I get an array out of bounds error.
I know Simulink can handle this size of calculation in a timestep as I have much larger equations running in S-Functions in similar models.
Does anyone have any ideas how I can get around this array out of bound problem? (I've already switched to a variable step solver and have tried splitting the equation up into more bite-size chunks).
I know the obvious answer in that the equation is large so no need to remind me of that one ;-)
Many Thanks,
Ad
I keep running into the same problem using the embedded MATLAB blocks of simulink. Once the equations to be solved in my blocks reach a certain length I get an array out of bounds error.
I know Simulink can handle this size of calculation in a timestep as I have much larger equations running in S-Functions in similar models.
Does anyone have any ideas how I can get around this array out of bound problem? (I've already switched to a variable step solver and have tried splitting the equation up into more bite-size chunks).
Code:
function [p1_out,p2_out] = fcn(theta1,theta2)
pq1 = 2*a1*g*cos(theta2)*M2-2*a1*g*cos(theta1)^2*cos(theta2)*M2+a2*g*cos(theta2)^2*M2-2*a2*g*cos(theta1)^2*cos(theta2)^2*M2+M1*a1*g*cos(theta2)-M1*a1*g*cos(theta1)^2*cos(theta2)+sin(theta1)*M1*a1*g*sin(theta2)*cos(theta1)+2*sin(theta1)*a1*g*sin(theta2)*cos(theta1)*M2-sin(theta1)*a1*M2(g*(sin(theta1)*cos(theta2)+cos(theta1)*sin(theta2)))-sin(theta1)*a2*M2(g*(sin(theta1)*cos(theta2)+cos(theta1)*sin(theta2)))*cos(theta2)+2*sin(theta1)*a2*g*sin(theta2)*cos(theta1)*cos(theta2)*M2-a2*M2(g*(sin(theta1)*cos(theta2)+cos(theta1)*sin(theta2)))*sin(theta2)*cos(theta1)+a2*g*cos(theta1)^2*M2
pq2 = 1; % this will be changed to an equation later
p1_out = pq1;
p2_out = pq2;
I know the obvious answer in that the equation is large so no need to remind me of that one ;-)
Many Thanks,
Ad