Lsqcurvefit for 2 parameters

1 回表示 (過去 30 日間)
Laura
Laura 2013 年 11 月 19 日
編集済み: Matt J 2013 年 11 月 19 日
I read over the lsqcurvefit for one parameter.
x=lsqcurvefit(fun,xo,xdata,ydata)
where xo= initial x,
fun is the function to calculate xdata at xo.
I have 2 parameters needs to adjust to get xdata
let say xo,yo are two initial conditions. fun is the function to calculate xdata at xo,yo
How do I use lsqcurvefit to find the right x,y values.
For example:
xdata=[ 1 2]; ydata=[0.9 1.5];
Initial guess xo=1, yo=10^-4
fun: is the function which I dont know the specific form and that is my code to calculate xdata based on xo,yo.
Now I want to find the correct xo,yo.
I could not access the link that you gave.
  1 件のコメント
Sean de Wolski
Sean de Wolski 2013 年 11 月 19 日
Can you provide an actual example of what you have?
The documentation gives some examples of using lsqcurvefit.

サインインしてコメントする。

採用された回答

Matt J
Matt J 2013 年 11 月 19 日
編集済み: Matt J 2013 年 11 月 19 日
I read over the lsqcurvefit for one parameter. x=lsqcurvefit(fun,x0,xdata,ydata)
No, this is not a 1-parameter syntax. x and x0 are vectors. If you pass a 2x1 initial vector x0 as input, then lsqcurvefit will know that fun(x,xdata) is a function of a 2x1 parameter vector x.
  2 件のコメント
Laura
Laura 2013 年 11 月 19 日
You meant that if I give xo=[ 1 10^-4]. It will give me 2 parameters for x which is x and y?
Matt J
Matt J 2013 年 11 月 19 日
編集済み: Matt J 2013 年 11 月 19 日
Yes. But you must write your fun(x,xdata) so that it expects x to be 1x2 vector argument as well.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDownloads についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by