Effacer les filtres
Effacer les filtres

Using Fminsearch to Minimize Data difference

3 vues (au cours des 30 derniers jours)
Suki Sule
Suki Sule le 25 Fév 2016
Commenté : Star Strider le 26 Fév 2016
I need to create a function that can be passed to fminsearch. I want to get argmink =||ak-d||^2, where a is a time series output ie x,y (amplitude/time) and d is another different time series output signal. I need to find the value of k that will cause convergence or give the minimum difference value between a and d. So I want to use fminsearch to do this. Some pointer will be very useful. Thanks.

Réponses (1)

Star Strider
Star Strider le 26 Fév 2016
If I understand correctly what you want to do, this works:
d = randi(9, 10, 1); % Create Data
a = randi(9, 10, 1); % Create Data
argmin_k = @(k) norm(a*k-d).^2; % ‘argmin’ Function
[k,normval] = fminsearch(argmin_k, 1);
  3 commentaires
Suki Sule
Suki Sule le 26 Fév 2016
Or do I have to run fminsearch separately for each parameter, f(k1) then f(k2)...f(kn)
Star Strider
Star Strider le 26 Fév 2016
Thank you!
I am not certain what you want to do. For ‘k’ to be a vector, ‘k’ would have to be the same length as ‘a’ and ‘d’, and you would then use element-wise multiplication (.*) in your ‘argmin_k’ function.
The code changes to:
d = randi(9, 10, 1); % Create Data
a = randi(9, 10, 1); % Create Data
argmin_k = @(k) norm(a.*k-d).^2; % ‘argmin’ Function
K0 = ones(size(d)); % Vector ‘k’ Is The Same Length As The Data Vectors
[k,normval] = fminsearch(argmin_k, K0);

Connectez-vous pour commenter.

Catégories

En savoir plus sur Nonlinear Optimization dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by