How do i solve this matrix by using lsqcurvefit ?

.

1 commentaire

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?

Connectez-vous pour commenter.

 Réponse acceptée

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 commentaires

Thu N
Thu N le 25 Mar 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;

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by