Azzera filtri
Azzera filtri

Using Fminsearch to Minimize Data difference

3 visualizzazioni (ultimi 30 giorni)
Suki Sule
Suki Sule il 25 Feb 2016
Commentato: Star Strider il 26 Feb 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.

Risposte (1)

Star Strider
Star Strider il 26 Feb 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 Commenti
Suki Sule
Suki Sule il 26 Feb 2016
Or do I have to run fminsearch separately for each parameter, f(k1) then f(k2)...f(kn)
Star Strider
Star Strider il 26 Feb 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);

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by