필터 지우기
필터 지우기

one error in fminsearch?

조회 수: 2 (최근 30일)
Parham Babakhani Dehkordi
Parham Babakhani Dehkordi 2015년 3월 31일
댓글: Parham Babakhani Dehkordi 2015년 3월 31일
I tried to use fminsearch to solve an equation with three unknown parameters but there is an error:
fi1=[0.6787*1.0e-5 0.4520*1.0e-5 0.3519*1.0e-5 0.2655*1.0e-5 0.2317*1.0e-5]; Hw=[0.3974 0.3186 0.2612 0.1816 0.1284];
The function is: error=fi1-(A+(B*(Hw^n))); I would like to compute A,B and n. Initial guess; A=0.005, B=0.4, n=2
The codes are but error say define B?
error=inline(fi1-(A+(B.*(Hw.^n)))); xo=[0.005 0.4 2]; [x,fval,exitflag,output] = fminsearch(error,x0)

채택된 답변

Torsten
Torsten 2015년 3월 31일
error=@(x)(fi1-(x(1)+x(2)*Hw.^x(3)))*(fi1-(x(1)+x(2)*Hw.^x(3)))';
x0=[0.005 0.4 2];
[x,fval,exitflag,output] = fminsearch(error,x0);
Best wishes
Torsten.
  댓글 수: 1
Parham Babakhani Dehkordi
Parham Babakhani Dehkordi 2015년 3월 31일
Thank you Torsten, I copied your codes into my script, again there is an error as follows:
Attempt to execute SCRIPT fminsearch as a function: C:\Users\nima\Desktop\interfacial tensions\fminsearch.m
Error in interfacial_friction_factors (line 42) [x,fval,exitflag,output] = fminsearch(error,x0);

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by