Error in a function automatically generated by matlabFunction

Hi everyone. I'm working with a large symbolic matrix and I converted this matrix in a function with matlabFunction command. After 8 hours of processing, MATLAB give me a function that doesn't work. This is the error:
>> A_lin(1e-5, 1e-5, 1e-5, 0, 0, 0, 1, 9.81, 1, 1, 0.1, 0.1, 0.5)
Unrecognized function or variable 'beta_Var'.
Error in A_lin (line 509)
A =
ft_1({L,beta_Var,beta_r,g,k,m,t10,t100,t101,t104,t1043,t1047,t1048,t1049,t105,t1052,t106,t107,t1074,t1075,t108,t1085,t1088,t1089,t109,t1092,t11,t110,t111,t112,t1123,t1127,t113,t1133,t1134,t114,t1140,t115,t1170,t1176,t1177,t118,t1181,t1183,t119,t12,t121,t122,t124,t125,t1258,t126,t1265,t1266,t1267,t1268,t1269,t1277,t1281,t129,t13,t130,t132,t1327,t134,t1348,t135,t1354,t136,t137,t138,t139,t1398,t14,t140,t1403,t1404,t142,t143,t144,t1456,t146,t1462,t1463,t147,t1473,t1474,t148,t149,t15,t151,t153,t1533,t1547,t156,t157,t158,t1591,t1595,t1596,t16,t160,t1608,t161,t1610,t1611,t164,t165,t1663,t1689,t1698,t17,t170,t171,t172,t173,t1735,t1738,t1739,t1749,t1753,t179,t1793,t1794,t18,t1808,t181,t1813,t1814,t1815,t1816,t1818,t182,t1825,t1826,t1827,t1828,t1829,t1833,t1834,t1836,t187,t188,t189,t19,t190,t191,t192,t193,t1970,t1986,t1987,t199,t1999,t2,t20,t200,t201,t2011,t202,t204,t205,t206,t208,t209,t21,t210,t22,t220,t222,t223,t224,t225,t23,t238,t239,t24,t240,t241,t242,t246,t247,t248,t249,t25,t250,t251,t252,t255,t256,t26,t260,t262,t263,t265,t266,t267,t27,t273,t278,t279,t28,t280,t282,t284,t285,t286,t287,t288,t29,t292,t298,t30,t300,t301,t302,t303,t304,t305,t307,t308,t309,t31,t310,t311,t312,t313,t318,t319,t32,t320,t322,t323,t324,t325,t33,t331,t332,t335,t336,t337,t339,t34,t340,t341,t342,t343,t344,t346,t347,t348,t349,t35,t352,t353,t355,t356,t357,t36,t360,t361,t362,t363,t364,t366,t367,t369,t37,t370,t371,t376,t377,t378,t379,t38,t386,t387,t388,t389,t39,t392,t393,t395,t399,t4,t40,t400,t401,t402,t403,t407,t409,t41,t411,t412,t415,t416,t417,t418,t42,t420,t421,t422,t428,t429,t43,t432,t434,t44,t440,t443,t445,t447,t449,t45,t451,t452,t46,t469,t47,t470,t476,t48,t483,t49,t498,t5,t50,t501,t503,t504,t507,t51,t514,t518,t52,t524,t527,t533,t534,t55,t551,t554,t559,t56,t560,t561,t562,t57,t58,t59,t60,t609,t61,t62,t63,t64,t65,t66,t67,t68,t686,t688,t69,t7,t70,t71,t72,t73,t74,t75,t76,t77,t78,t787,t79,t790,t8,t80,t81,t82,t83,t830,t834,t835,t838,t84,t846,t85,t853,t855,t87,t88,t883,t884,t887,t888,t89,t9,t90,t905,t906,t908,t91,t92,t922,t926,t928,t93,t95,t96,t963,t967,t968,t97,t970,t971,t977,t98,t981,t983,t984,t985,t99,t993,t996,t997,t998,theta0,theta0_dot,theta1,theta1_dot,theta_r_dot});

3 Commenti

Did you define the input variable beta_Var?
What you have shown is a prt of the code, not the full code.
Nope! The signature of A_lin is:
A_lin(theta_r, theta_0, theta_1, theta_dot_r, theta_dot_0, theta_dot_1, m, g, k, L, D, beta, beta_r)
Inside automatially generated function, MATLAB declare a new variable beta_Var instead of beta.

Accedi per commentare.

Risposte (1)

If you look at https://www.mathworks.com/matlabcentral/answers/513625-how-to-save-a-symbolic-equation-in-a-txt-file#comment_817290 then you will see that inside the Symbolic Engine, MATLAB sometimes uses beta_Var when the user requested beta . Then the MATLAB level is usually responsible for mapping beta_Var back to beta .
MATLAB uses beta_Var to avoid conflict with the beta() function.
There might be bugs that lead to beta_Var not being renamed to beta sometimes.
The work-around is to rename your symbolic variable from beta to something else.

Prodotti

Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by