Find the value of a and k that minimise RMSE
1 view (last 30 days)
Show older comments
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])
0 Comments
Answers (1)
Ben Drebing
on 21 Dec 2017
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
0 Comments
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!