matlabFunction is too slow

조회 수: 8 (최근 30일)
Marrie
Marrie 2013년 12월 11일
댓글: Brad Carman 2014년 10월 16일
Hi all,
I am using matlabFunction to create a .m file to define the function of a vector and its Jacobian:
matlabFunction(fvec, J, 'file', filename, 'vars', {x, phi_old});
When the dimension of the vector = 50, the time cost is reasonable; but when setting the dimension to 500, it becomes extremely slow. Would you please give advice for this problem?
Thank you.

채택된 답변

Alan Weiss
Alan Weiss 2013년 12월 12일
I have no general advice. Perhaps if we saw a small snippet of your code we could help.
It is possible that your Jacobian is sparse, meaning it has a lot of zeros. In that case, it might be possible to avoid using matlabFunction at all, and simply use the JacobPattern option to have sparse finite differencing instead of time-consuming analytic calculations. Or perhaps there could be a hybrid sort of solution, where you explicitly calculate analytically (with matlabFunction) only the nonzero terms in the Jacobian. But this would require you to write a custom program.
Or it could be something as simple as declaring your symbolic variables to be real, which sometimes (but not often) saves time in matlabFunction.
Sorry I have nothing so helpful. There is simply a lot of calculation to be done, and it uses a lot of memory and time.
Alan Weiss
MATLAB mathematical toolbox documentation
  댓글 수: 1
Brad Carman
Brad Carman 2014년 10월 16일
What is the "JacobPattern option"?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by