This expression is too large.

The following error message occurred while using the .m file in simulink. I was going to simulate a 7x7 manipulator with simulink.
get_MassMatrix65
This expression is too large. Store partial results in temporary variables to split the expression into smaller parts.
Is there any other way to break an expression into variables?

回答 (1 件)

Steven Lord
Steven Lord 2023 年 6 月 18 日

0 投票

If you're generating the code for your block from a symbolic expression using matlabFunction or matlabFunctionBlock, as I suspect is the case, have you disabled optimization by specifying the name-value argument Optimize=false? If so try to re-enable optimization by omitting that name-value argument entirely (to use the default of Optimize=true.)

5 件のコメント

Walter Roberson
Walter Roberson 2023 年 6 月 18 日
Caution:
In several releases, optimize true malfunctioned, sometimes greatly. I have not tested in the two most recent releases.
진웅 이
진웅 이 2023 年 6 月 19 日
t3206 = t2855+t2856+t2857+t2858+t2859+t2860+t2861+t2862+t2863+t2864+t2865+t2866+t2867+t2868+t2869+t2870+t2871+t2872+t2873+t2874+t2875+t2876+t2877+t2878+t2879+t2880+t2881+t2882+t2883+t2884+t2885+t2886+t2887+t2888+t2889+t2890+t2891+t2892+t2893+t2894+t2895+t2896+t2897+t2898+t2899+t2900+t2901+t2902+t2903+t2904+t2905+t2906+t2907+t2908+t2909+t2910+t2911+t2912+t2913+t2914+t2915+t2916+t2917+t2918+t2919+t2920+t2921+t2922+t2923+t2924+t2925+t2926+t2927+t2928+t2929+t2930+t2931+t2932+t2933+t2934+t2935+t2936+t2937+t2938+t2939+t2940+t2941+t2942+t2943+t2944+t2945+t2946+t2947+t2948+t2949+t2950+t2951+t2952+t2953+t2954+t2955+t2956+t2957+t2958+t2959+t2960+t2961+t2962+t2963+t2964+t2965+t2966+t2967+t2968+t2969+t2970+t2971+t2972+t2973+t2974+t2975+t2976+t2977+t2978+t2979+t2980+t2981+t2982+t2983+t2984+t2985+t2986+t2987+t2988+t2989+t2990+t2991+t2992+t2993+t2994+t2995+t2996+t2997+t2998+t2999+t3000+t3001+t3002+t3003+t3004+t3005+t3006+t3007+t3008+t3009+t3010+t3011+t3012+t3013+t3014+t3015+t3016+t3017+t3018+t3019+t3020+t3021+t3022+t3023+t3024+t3025+t3026+t3027+t3028+t3029+t3030+t3031+t3032+t3033+t3034+t3035+t3036+t3037+t3038+t3039+t3040+t3041+t3042+t3043+t3044+t3045+t3046+t3047+t3048+t3049+t3050+t3051+t3052+t3053+t3054+t3055+t3056+t3057+t3058+t3059+t3060+t3061+t3062+t3063+t3064+t3065+t3066+t3067+t3068+t3069+t3070+t3071+t3072+t3073+t3074+t3075+t3076+t3077+t3078+t3079+t3080+t3081+t3082+t3083+t3084+t3085+t3086+t3087+t3088+t3089+t3090+t3091+t3092+t3093+t3094+t3095+t3096+t3097+t3098+t3099+t3100+t3101+t3102+t3103+t3104+t3105+t3106+t3107+t3108+t3109+t3110+t3111+t3112+t3113+t3114+t3115+t3116+t3117+t3118+t3119+t3120+t3121+t3122+t3123+t3124+t3125+t3126+t3127+t3128+t3129+t3130+t3131+t3132+t3133+t3134+t3135+t3136+t3137+t3138+t3139+t3140+t3141+t3142+t3143+t3144+t3145+t3146+t3147+t3148+t3149+t3150+t3151+t3152+t3153+t3154+t3155+t3156+t3157+t3158+t3159+t3160+t3161+t3162+t3163+t3164+t3165+t3166+t3167+t3168+t3169+t3170+t3171+t3172+t3173+t3174+t3175+t3176+t3177+t3178+t3179+t3180+t3181+t3182+t3183+t3184+t3185+t3186+t3187+t3188+t3189+t3190+t3191+t3192+t3193+t3194+t3195+t3196+t3197+t3198+t3199+t3200+t3201+t3202+t3203+t3204+t3205-t11532-t11534-t11537-t11538-t11540-t11546-t11551-t11554-t11555-t11559-t11560-t11561-t11563-t11567-t11568-t11569-t11573-t11574-t11578-t11580-t11581-t11583-t11584-t11592-t11595-t11601-t11602-t11610-t11618-t11621-t11622-t11628-t11632-t11633-t11634-t11639-t11656-t11662-t11665-t11667-t11668-t11669-t11670-t11671-t11672-t11681-t11684-t11686-t11690-t11697-t11698-t11706-t11707-t11713-t11715-t11717-t11718-t11721-t11727-t11729-t11737-t11738-t11741-t11744-t11745-t11761-t11762-t11763-t11764-t11767-t11768-t11781-t11782-t11783-t11784-t11785-t11786-t11790-t11792-t11794-t11797-t11798-t11799-t11804-t11805-t11806-t11807-t11812-t11817-t11821-t3.*t4.*t7.*t13.*3.731166785767855e-3-t3.*t4.*t5.*t10.*t14.*1.185446863937387e-3-t3.*t4.*t8.*t9.*t14.*5.367504695157484e-3-t3.*t4.*t7.*t8.*t9.*t10.*1.272243011263065e-3-t2.*t3.*t4.*t7.*t13.*t17.*3.55634059181216e-3-t3.*t4.*t5.*t7.*t13.*t15.*1.758741834919224e-3;
The above calculation formula is too long, so it seems to be a problem.Splitting the equation using variables solves the problem. Is there a simpler way?
Walter Roberson
Walter Roberson 2023 年 6 月 19 日
That does not seem to cause problems when I test ?
t3206 = str2sym('t2855+t2856+t2857+t2858+t2859+t2860+t2861+t2862+t2863+t2864+t2865+t2866+t2867+t2868+t2869+t2870+t2871+t2872+t2873+t2874+t2875+t2876+t2877+t2878+t2879+t2880+t2881+t2882+t2883+t2884+t2885+t2886+t2887+t2888+t2889+t2890+t2891+t2892+t2893+t2894+t2895+t2896+t2897+t2898+t2899+t2900+t2901+t2902+t2903+t2904+t2905+t2906+t2907+t2908+t2909+t2910+t2911+t2912+t2913+t2914+t2915+t2916+t2917+t2918+t2919+t2920+t2921+t2922+t2923+t2924+t2925+t2926+t2927+t2928+t2929+t2930+t2931+t2932+t2933+t2934+t2935+t2936+t2937+t2938+t2939+t2940+t2941+t2942+t2943+t2944+t2945+t2946+t2947+t2948+t2949+t2950+t2951+t2952+t2953+t2954+t2955+t2956+t2957+t2958+t2959+t2960+t2961+t2962+t2963+t2964+t2965+t2966+t2967+t2968+t2969+t2970+t2971+t2972+t2973+t2974+t2975+t2976+t2977+t2978+t2979+t2980+t2981+t2982+t2983+t2984+t2985+t2986+t2987+t2988+t2989+t2990+t2991+t2992+t2993+t2994+t2995+t2996+t2997+t2998+t2999+t3000+t3001+t3002+t3003+t3004+t3005+t3006+t3007+t3008+t3009+t3010+t3011+t3012+t3013+t3014+t3015+t3016+t3017+t3018+t3019+t3020+t3021+t3022+t3023+t3024+t3025+t3026+t3027+t3028+t3029+t3030+t3031+t3032+t3033+t3034+t3035+t3036+t3037+t3038+t3039+t3040+t3041+t3042+t3043+t3044+t3045+t3046+t3047+t3048+t3049+t3050+t3051+t3052+t3053+t3054+t3055+t3056+t3057+t3058+t3059+t3060+t3061+t3062+t3063+t3064+t3065+t3066+t3067+t3068+t3069+t3070+t3071+t3072+t3073+t3074+t3075+t3076+t3077+t3078+t3079+t3080+t3081+t3082+t3083+t3084+t3085+t3086+t3087+t3088+t3089+t3090+t3091+t3092+t3093+t3094+t3095+t3096+t3097+t3098+t3099+t3100+t3101+t3102+t3103+t3104+t3105+t3106+t3107+t3108+t3109+t3110+t3111+t3112+t3113+t3114+t3115+t3116+t3117+t3118+t3119+t3120+t3121+t3122+t3123+t3124+t3125+t3126+t3127+t3128+t3129+t3130+t3131+t3132+t3133+t3134+t3135+t3136+t3137+t3138+t3139+t3140+t3141+t3142+t3143+t3144+t3145+t3146+t3147+t3148+t3149+t3150+t3151+t3152+t3153+t3154+t3155+t3156+t3157+t3158+t3159+t3160+t3161+t3162+t3163+t3164+t3165+t3166+t3167+t3168+t3169+t3170+t3171+t3172+t3173+t3174+t3175+t3176+t3177+t3178+t3179+t3180+t3181+t3182+t3183+t3184+t3185+t3186+t3187+t3188+t3189+t3190+t3191+t3192+t3193+t3194+t3195+t3196+t3197+t3198+t3199+t3200+t3201+t3202+t3203+t3204+t3205-t11532-t11534-t11537-t11538-t11540-t11546-t11551-t11554-t11555-t11559-t11560-t11561-t11563-t11567-t11568-t11569-t11573-t11574-t11578-t11580-t11581-t11583-t11584-t11592-t11595-t11601-t11602-t11610-t11618-t11621-t11622-t11628-t11632-t11633-t11634-t11639-t11656-t11662-t11665-t11667-t11668-t11669-t11670-t11671-t11672-t11681-t11684-t11686-t11690-t11697-t11698-t11706-t11707-t11713-t11715-t11717-t11718-t11721-t11727-t11729-t11737-t11738-t11741-t11744-t11745-t11761-t11762-t11763-t11764-t11767-t11768-t11781-t11782-t11783-t11784-t11785-t11786-t11790-t11792-t11794-t11797-t11798-t11799-t11804-t11805-t11806-t11807-t11812-t11817-t11821-t3.*t4.*t7.*t13.*3.731166785767855e-3-t3.*t4.*t5.*t10.*t14.*1.185446863937387e-3-t3.*t4.*t8.*t9.*t14.*5.367504695157484e-3-t3.*t4.*t7.*t8.*t9.*t10.*1.272243011263065e-3-t2.*t3.*t4.*t7.*t13.*t17.*3.55634059181216e-3-t3.*t4.*t5.*t7.*t13.*t15.*1.758741834919224e-3')
t3206 = 
matlabFunction(t3206, 'file', 't3206.m', 'optimize', false)
ans = function_handle with value:
@t3206
Laribi Nessrine
Laribi Nessrine 2023 年 11 月 3 日
I have the same problem could you tell me please where i can find "optimization setting" in simulink. Thanks
Walter Roberson
Walter Roberson 2023 年 11 月 3 日
There is no relevant optimization setting in Simulink. The long expression with t2855 and so on is output from having used matlabFunction on a symbolic expression and having asked it to write to a file. I showed above how to turn off optimization when you do that:
matlabFunction(t3206, 'file', 't3206.m', 'optimize', false)

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeManual Performance Optimization についてさらに検索

タグ

質問済み:

2023 年 6 月 18 日

コメント済み:

2023 年 11 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by