필터 지우기
필터 지우기

Using Fminsearch to Minimize Data difference

조회 수: 3 (최근 30일)
Suki Sule
Suki Sule 2016년 2월 25일
댓글: Star Strider 2016년 2월 26일
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.

답변 (1개)

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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surrogate Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by