fsolve accuracy

조회 수: 13 (최근 30일)
John Mulvihill
John Mulvihill 2011년 11월 17일
댓글: John Mulvihill 2014년 4월 24일
Hi all,
I am fairly new to matlab so excuse my ignorance as this could be an easy problem.
I am using the fsolve function and it is working fine and it outputs my three parameters that I need. However all three numbers are limited to an accuracy of four decimal places which I would like to increase to 6 or even more.
Does anyone have any advice to help me improve the accuracy? This is a snapshot of the code...
Init_Guess = [0.05 0.02 0.0000406];
options=optimset('Display','iter','MaxIter',3000,'MaxFunEvals',3000, 'TolFun', 1.0e-12, 'TolX',1.0e-12);
Coeffs = fsolve(@Solution_1,Init_Guess,options)
As you can see with the Initial guess I am trying to force the code to increase the decimal places but it doesn't seem to want to do it.
Regards
John Mulvihill

채택된 답변

the cyclist
the cyclist 2011년 11월 17일
My guess is that you are talking about what is displayed, as opposed to what is calculated. Try typing
>> format long
to see more digits in the output of the command window.

추가 답변 (1개)

Mahyar
Mahyar 2014년 4월 24일
I have same problem too, and tried format long but it does not have any effect of the meaningful digits of results. Am I wrong?!
  댓글 수: 1
John Mulvihill
John Mulvihill 2014년 4월 24일
Hey Mahyar,
This answer from the cyclist solved it for me from what I remember! When I run the "fsolve" function in my code it calls on another .m file (Solution_1 from the example I gave) and within this file I have placed "format long" just after the "function" line which gives me 15 decimal places answers.
Example of Solution_1 file:
function Cost = Solution_1(Init_Guess)
format long
C1 = Init_Guess(1); C2 = Init_Guess(2); % these are the answers I want for whatever equation I put in
Cost = sum(C1 - C2) % this doesn't matter
end
The answer I get from this looks like the folllowing:
C1 = 0.008198986069043 and C2 = 0.005224578396002
Hope this helps
John

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by