Using fminsearch to determine variables

2 ビュー (過去 30 日間)
Jordan Rosales
Jordan Rosales 2021 年 3 月 14 日
コメント済み: Walter Roberson 2021 年 3 月 15 日
Currently I am working on estimating two different variables of a sigmoid curve graph, the first variable 'z(1)' is the slope of the sigmoid curve and 'z(2)' is half of the maximum height of the curve. I currently have an equation that outputs y-values of the curve, "E" based on these variables and the input/x value of 'C1': E=C1.^z(1)./(z(2)^z(1)+C1.^z(1)
I need to use fminsearch to calculate the values of 'z(1)' and 'z(2)'.
For the function tag I created:
f=@(z)C1.^z(1)./(z(2)^z(1)+C1.^z(1))
and then typed out
params=fminsearch(f,[1, 0.55])
with 1 and 0.55 being my guesses for the approximate half maximum value, and the slope of the sigmoid curve, respectively.
When I run the function it outputs an error on the fminsearch line I created: 'Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 41-by-1.'
Any help with fixing this would be appreciated!

回答 (1 件)

Star Strider
Star Strider 2021 年 3 月 15 日
The fminsearch function (and all other optimization functions I know of) want a scalar result from the function they are optimising.
In this instance, I would use:
f=@(z,C1) C1.^z(1)./(z(2)^z(1)+C1.^z(1));
params=fminsearch(@(z) norm(y-f(z,C1)),[1, 0.55])
That should work. If it has problems, please post the entire error message (if it throws an error), or a reasonably detailed description of what it is not doing that you want it to do, or what it is doing that you do not want it to do.
  3 件のコメント
Star Strider
Star Strider 2021 年 3 月 15 日
I assume here that ‘z’ is the parameter vector, ‘y’ is the dependent variable and that ‘C1’ is the independent variable vector.
If that is not the situation, please define them so I can make appropriate changes to my code example.
Walter Roberson
Walter Roberson 2021 年 3 月 15 日
That is, in Star Strider's code, y stands for the vector of known output data values (must be a column vector) and C1 stands for the vector of known input data values (must be a column vector too)

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by