MATLAB Answers

0

when i use matlabFunction command matlab takes a long time to run it and then hangs?

Najmeh Eskandari さんによって質問されました 2018 年 11 月 7 日
最新アクティビティ Walter Roberson
さんによって コメントされました 2018 年 11 月 7 日
hi. I run the m file which is attached without 198 line(197 and 199 lines are in code) and matlab works correctly but when I add that line it takes a long time to run and Eventually the program will hang .197 and 199 lines are same as 198 and I don't know what is the problem?(C matrix is created correctly but Cfunc.m is not created)

  0 件のコメント

サインイン to comment.

1 件の回答

回答者: Walter Roberson
2018 年 11 月 7 日
 採用された回答

When you request saving to a file, the default is that optimization is turned on. Optimization can take a long long time and run out of memory.

  4 件のコメント

Your .m file does not happen to be part of your .zip
load UR10
syms( symvar(C) ); %not all the variables used in C are in the workspace
h = matlabFunction(C, 'vars', [a_2, a_3, d_4, d_5, d_6, Theta1, Theta2, Theta3, Theta4, Theta5, Theta6, dTheta1, dTheta2, dTheta3, dTheta4, dTheta5, dTheta6], 'optimize', false, 'File', 'Cfunc.m')
This is not exactly what you would call "fast". It expands to over 16 megabytes.
There are cases where symbolic expressions that take only a relatively small space in a .mat file (e.g., 10 kilobytes) can end up taking a long long long time to write out. I have a support case open in which I found that a small symbolic .mat lead to something that took more than 24 hours to write to file even without matlabFunction processing, just telling MuPAD to write to a file as text.
yes. I forgot to put it in folder
Anyhow,l the matlabFunction line I show is what you need. You might want to change the order of the variables. I do recommend using the 'vars' option, as otherwise the variables will end up in an order that probably does not make intuitive sense, making it more likely that you would encounter errors in passing variables in.

サインイン to comment.



Translated by