필터 지우기
필터 지우기

lsqnonlin question

조회 수: 6 (최근 30일)
Shalini
Shalini 2012년 4월 18일
Consider the following code:
X(1:10304)=xlsread('qs_comp_2.xls',2,'G3822:G14125');
Y(1:10304)=xlsread('qs_comp_2.xls',2,'H3822:H14125');
X(10305:12631)=xlsread('comp.xls',3,'T4259:T6585');
Y(10305:12631)=xlsread('comp.xls',3,'U4259:U6585');
X0=[1012 1400 0.17 -0.0001];
lb = [1012;900;0.17;-0.0001];
ub=[1300;1600;0.3119;10];
StartAt = [1012;900;0.17;-0.0001];
options = optimset('MaxFunEvals',10000);
x=lsqnonlin(@(X0)fit_simp(X0,X,Y),StartAt,lb,ub,options);
[total_readings,epsilon_dot_QS,epsilon_dot_MR] = GetMRDetails;
for i=1:total_readings
Y_new(i)=(X0(1)+X0(2)*(X(i)^X0(3))+X0(4)*log(epsilon_dot_QS/epsilon_dot_MR));
end
Please can anyone help me here:
1) Is the final optimised vector X0 or is it x? That is: which id the final answer X0 or X 2)Is there anything I'm missing in this code?

답변 (2개)

Sean de Wolski
Sean de Wolski 2012년 4월 18일
It is x, the output from lsqnonlin. It doesn't look like the above code ever uses the actual optimized value.
  댓글 수: 1
Shalini
Shalini 2012년 4월 18일
Please can you correct it-I shall be grateful.I'm new to matlab

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


Shalini
Shalini 2012년 4월 18일
Why you think so?
My fit_simp function (see properly above) is as below
function diff = fit_simp(x,X,Y)
% This function is called by lsqnonlin.
% x is a vector which contains the coefficients of the
% equation. X and Y are the option data sets that were
% passed to lsqnonlin.
A=x(1);
B=x(2);
n=x(3);
C=x(4);
[total_readings,epsilon_dot_QS,epsilon_dot_MR] = GetMRDetails;
for i=1:total_readings
diff(i)=(A+B*(X(i)^n)+C*log(epsilon_dot_QS/epsilon_dot_MR));
diff(i)=diff(i)-Y(i);
end
  댓글 수: 2
Sean de Wolski
Sean de Wolski 2012년 4월 18일
That looks fine, it's that your call to LSQNONLIN generates a vector called 'x'. This vector is not used in the remainder of the code you showed us.
Shalini
Shalini 2012년 4월 18일
ok, i will correct that- 2 questions:
1)IS optimisation code correct?
2) I want to outtput the adjusted R square, how to do that?
Shalini

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by