How do i solve this matrix by using lsqcurvefit ?

.

1 comentario

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?

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 25 de Mzo. de 2018
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 comentarios

Thu N
Thu N el 25 de Mzo. de 2018
Sorry, it's a typo. I have posted the code again.
Walter Roberson
Walter Roberson el 25 de Mzo. de 2018
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;

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

el 25 de Mzo. de 2018

Editada:

el 25 de Mzo. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by