Calculating the gradient of a function
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello. I want to calculate the gradient of this function at the point xc:
function MSE=mseFunction(alpha,beta,y,yS)
MSE = [alpha beta; y yS];
end
xc = [100; 102];
y = 20;
yS = 50;
how I should proceed. Thanks!
0 Kommentare
Antworten (1)
Marco Morganti
am 5 Jan. 2017
Bearbeitet: Marco Morganti
am 6 Jan. 2017
Hi Amine,
you could use gradient() along with symbolic variables to find the gradient of your function MSE().
syms parameters;
f = mseFunction(parameters);
g = gradient(f);
at this point you can evaluate g() at the desired point:
g_xc = eval(subs(g,xc));
I hope this helps
4 Kommentare
Walter Roberson
am 5 Jan. 2017
syms parameters;
f = mseFunction(parameters);
g = gradient(f);
gfun = matlabFunction(g); %rather than eval()
g_xc = gfun(xc);
Siehe auch
Kategorien
Mehr zu Conversion Between Symbolic and Numeric finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!