fitting a scatter plot to power law

2 ビュー (過去 30 日間)
Joseph
Joseph 2019 年 9 月 24 日
編集済み: Star Strider 2019 年 9 月 24 日
I have an array A(5,2). how can i fit it to a power law y= c1*x^n1+c2*x^n2 in wich C1, C2, n1 and n2 are real numbers and yet to be determined from the fit?
Thank you

採用された回答

Star Strider
Star Strider 2019 年 9 月 24 日
編集済み: Star Strider 2019 年 9 月 24 日
One approach:
objfcn = @(b,x) b(1).*x.^b(3) + b(2).*x.^b(4);
x = 1:10; % Create Data
y = rand(1, 10); % Create Data
B0 = ones(4,1);
[B,rsdnrm] = fminsearch(@(b) norm(y - objfcn(b,x)), B0);
fprintf(1, 'c_1 = %12.6f\nc_2 = %12.6f\nn_1 = %12.6f\nn_2 = %12.6f\n', B)
Experiment to get the result you want.
EDIT — (24 Sep 2019 at 15:19)
I have no idea how ‘A’ fits into this, since it was not described in any detail.
A guess:
[B,rsdnrm] = fminsearch(@(b) norm(A(:,2) - objfcn(b,A(:,1))), B0);
This fits the second column of ‘A’ to the first column, using the function. Reverse the column designations if necessary.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by