Find argmin of function with unique vector
Afficher commentaires plus anciens
Hi,
I want to solve the next problem:
For example, for
and 
I tried to do some things like:
x=[theta,1-theta];
x0 =[0.0001,0.0001];
fun = @(x)sum((x-y)./x);
x = fminsearch(fun,x0);
Any idea how to minimize vector with respect to this scalar?
I know I can just write it like that:
x0 =[0.0001,0.0001];
fun = @(x) (x-y(1))/x + ((1-x)-y(2))/x
x = fminsearch(fun,x0);
But there are more dimensions (then 2) in the original problem so it is impractical to do so.
Thanks!
3 commentaires
infinity
le 24 Juin 2019
Hello,
What is "n" in the formula?
Since in your formula,
, where
is a vector.
How can we understand
?
DM
le 25 Juin 2019
Kaustav Bhattacharya
le 25 Juin 2019
If you know n can you not use
x0 = ones(1,n)*0.0001
and then
x = fminsearch(fun,x0) ?
Réponse acceptée
Plus de réponses (1)
Hello,
Here is an example that you can refer
I find mininum of function
, the initial guess is given by
. The code could be like that
clear
N = 5;
fun = @(t) norm(t,2);
x0 = 1+zeros(1,N);
x = fminsearch(fun,x0)
where I choose N = 5, but it can be changed.
Catégories
En savoir plus sur Assumptions dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
