Given a function f:R^600 -> R f(x)=0.5*norm(Ax-b)^2
, where A
is a 400x600 matrix, b
is 400x1, and both of them are given.
How can I get the gradient(f)
at some given x0
in MATLAB?
m=400
n=600
A=randn(m,n)
b=randn(m,1)
syms x
f= 0.5*norm(A*x-b)^2
gradient(f,x)
However it does not work because it seems it regard x
as scalar, not a vector.