nonlinear solver user specified function

조회 수: 3 (최근 30일)
msh
msh 2014년 11월 17일
댓글: Star Strider 2014년 11월 20일
Hi,
I would like to use a user specified non-linear solver as a substitute for the fsolve. This function is quite frequent in some Economics applications and it performs better in terms of efficiency and speed than the default options of matlab. Can someone help me on how i should modify my system in order to be able to call that function. I am attaching all the necessary files. The user specified nonlinear solver is the "csolve" file.
fyi, the code with fsolve it took around 30min to implement in my pc.
many thanks

답변 (2개)

Star Strider
Star Strider 2014년 11월 17일
Put it in your MATLAB user path (on Windows machines, C:\Users\...\Documents\MATLAB\...), then call it in your main script as you would any other function:
[x,rc] = csolve(FUN, x, ...);
  댓글 수: 5
Star Strider
Star Strider 2014년 11월 18일
My pleasure!
msh
msh 2014년 11월 19일
Star Strider: I manage to work it out, please check my answer. Fyi, to solve my own system I needed 30min with fsolve, but this function does it in 3-4 secs !!! So, I posted a simple example on how someone can use the "csolve".

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


msh
msh 2014년 11월 18일
편집: msh 2014년 11월 18일
Ok, I manage to work that function through this simple example. I am attaching the files of the example for how to construct the non-linear system and how to call the "csolve". The attachments include:
  • calc_ss ==> main program
  • neoclassical_stst.m ==> the function that defines the non-linear system
  • neoclassical_stst_csolve ==> Aux. Function to define parameters
  • csolve ==> the non-linear solver
So, if someone wants to use the "csolve" instead of Matlab's fsolve, by modifying his system according to the example I gave should work.
  댓글 수: 1
Star Strider
Star Strider 2014년 11월 20일
I honestly have nothing to contribute at this point. You’ve solved it.
I would encourage you to formalise your functions, document and explain them as elaborately as necessary (think about what you wanted to know when you first wanted to use them), include the appropriate citations, websites, and other references (the ones that I looked up, and others as necessary).
Then contribute the package to the File Exchange under your name. The ‘csolve’ function seems to be valuable, and by documenting them based on your explorations of them, you could make them available to others who are looking for an efficient nonlinear solver. They’re intended to be used with MATLAB, and I doubt the original authors of the routines would object, since the routines are freely available anyway but completely lack the documentation you will provide.

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

카테고리

Help CenterFile Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by