How do i solve this matrix by using lsqcurvefit ?

.

1 件のコメント

Star Strider
Star Strider 2018 年 3 月 25 日
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.
Walter Roberson
Walter Roberson 2018 年 3 月 25 日
In your modified code, the function that has the x parameter is named law1, but the anonymous function ffun calls upon lblaw1 instead.
Walter Roberson
Walter Roberson 2018 年 3 月 25 日
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