.

1 Kommentar

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?

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 25 Mär. 2018

0 Stimmen

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 Kommentare

Thu N
Thu N am 25 Mär. 2018
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;

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Gefragt:

am 25 Mär. 2018

Bearbeitet:

am 25 Mär. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by