Borrar filtros
Borrar filtros

Find the value of a and k that minimise RMSE

1 visualización (últimos 30 días)
Tsang Chak Ng
Tsang Chak Ng el 19 de Dic. de 2017
Respondida: Ben Drebing el 21 de Dic. de 2017
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])

Respuestas (1)

Ben Drebing
Ben Drebing el 21 de Dic. de 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

Categorías

Más información sobre Signal Integrity Kits for Industry Standards en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by