Code doesn't work on latest version of matlab.

조회 수: 5 (최근 30일)
Mat Hunt
Mat Hunt 2016년 7월 19일
댓글: Stephen23 2016년 7월 19일
I wrote a Newton solver in Matlab 2008 and it worked brilliantly. I now try it on an later version of matlab and it stops giving me the same results. I am at a loss as why this should be. Any suggestions?
  댓글 수: 2
Stephen23
Stephen23 2016년 7월 19일
편집: Stephen23 2016년 7월 19일
@Mat Hunt: note that you should use consistent indentation and code formatting to make your code easier to follow. With MATLAB it is very simple, because the editor does it for you by default. If for some reason the indentation has been lost, simply select the code and the press ctrl + i.
Also you should never use error as a variable name, because this is the name of a very important inbuilt function. Likewise you should never use size, length, i, j, cell, etc, etc.
Mat Hunt
Mat Hunt 2016년 7월 19일
Duly noted

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

채택된 답변

Stephen23
Stephen23 2016년 7월 19일
편집: Stephen23 2016년 7월 19일
MATLAB function outputs can change between versions:
as can the availability of functions, and what arguments they accept. There is no guarantee that code written for one version should work on another. It is up to the user to make their code work on versions different than that it was written for. For this reason MATLAB provides documentation on changes between releases:
  댓글 수: 8
Mat Hunt
Mat Hunt 2016년 7월 19일
The maths of the numerical solution is absolutely fine. It worked before and gave the answers expected. The code using matlab 2008a converged in around 3-4 steps showing that it was indeed a good method for the problem. The only issue is why doesn't it work in the 2013b version.
Stephen23
Stephen23 2016년 7월 19일
"The code using matlab 2008a converged in around 3-4 steps showing that it was indeed a good method for the problem"
Convergence in a few steps with one case does not prove anything about how suitable the method is for generally solving that problem: it might still be susceptible to slight changes in start values or due to the exact calculations performed. It could be a chaotic system when solved with that method.
In any case, you should start debugging to find out where the difference is.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by