フィルターのクリア

Find the value of a and k that minimise RMSE

1 回表示 (過去 30 日間)
Tsang Chak Ng
Tsang Chak Ng 2017 年 12 月 19 日
回答済み: Ben Drebing 2017 年 12 月 21 日
Hello,I am trying to find the value of a and k that minimise my function RMSE,I have input the following code,can I just asked where have I got wrong since Matlab asked me to have more arguments for some reason?
%lightprog
function RMSE=lightprog(V)
k=V(1);a=V(2)
stimulus=[2 4 6 8 10 12]
data=[1.1 1.5 2.1 2.5 2.9 3.2]
modelS=k*(stimulus.^a);
RMSE=sqrt(mean(modelS-data).^2)
return
[k,a]=fminsearch('lightprog',[0,0])

回答 (1 件)

Ben Drebing
Ben Drebing 2017 年 12 月 21 日
The function needs to be defined at the bottom of the file, if you would like to run your code in this way. Try:
[k,a]=fminsearch(@lightprog,[0,0])
function RMSE=lightprog(V)
k=V(1);a=V(2)
stimulus=[2 4 6 8 10 12]
data=[1.1 1.5 2.1 2.5 2.9 3.2]
modelS=k*(stimulus.^a);
RMSE=sqrt(mean(modelS-data).^2)
return
end

カテゴリ

Help Center および File ExchangeSignal Integrity Kits for Industry Standards についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by