.

댓글 수: 1

The code you posted has some significant inconsistencies:
ffun = @(C,wv1)lblaw1(C,wv1,a,b,c);
ax = lsqcurvefit(ffun,[2 3 4 5],v1,OD,[],[],options);
function fun = law1(C,v1,a,b,c)
fun = (a*C(1) + b*C(2) + c*C(3))* x;
For example, ‘v1’ does not appear in your ‘law1’ (or ‘lblaw1’) function calculation, so that is one problem.
Are you posting the code you are actually running?

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

 채택된 답변

Walter Roberson
Walter Roberson 2018년 3월 25일

0 개 추천

In your code
function fun = law1(C,v1,a,b,c)
fun = (a*C(1) + b*C(2) + c*C(3))* x;
x is not defined.
The C corresponds to the current trial parameters, and v1 corresponds to xdata. You are ignoring the xdata input, v1, and instead using an undefined variable or function named x.

댓글 수: 3

Thu N
Thu N 2018년 3월 25일
Sorry, it's a typo. I have posted the code again.
In your modified code, the function that has the x parameter is named law1, but the anonymous function ffun calls upon lblaw1 instead.
In your most recent version of the code,
ffun = @(C,wv1)lblaw1(C,wv1,eox,edx,ecc);
passes 5 parameters to lblaw1, but
function fun = lblaw1(C,v1,a,b,c,x)
needs 6 parameters.
What I think is that you should be using
function fun = law1(C,x,a,b,c)
fun = (a*C(1) + b*C(2) + c*C(3))* x;

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

추가 답변 (0개)

질문:

2018년 3월 25일

편집:

2018년 3월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by