help with fminsearch output value
2 次查看(过去 30 天)
显示 更早的评论
Hi all,
I'm trying to understand the use of fminsearch, to find the argument that minimizes the difference between two data sets (one experimental and several theoretical ones). As described in some articles, the mathematical expression is : min(mean(Xi-X_av).^2), were Xi = Experimental/theory(n) and X_av is the average off all the Xi.
As a test, I created a simple function as the experimental (EXP) and theory (Xi).
a = [1:10]';
EXP = exp(a*0.2);
coeff = [0.1,0.13,0.15,0.17,0.2];
theo = exp(a.*coeff)
Xi = EXP./(theo);
It can be seen that (a) are the row numbers. There are 5 arrays corresponding to the different functions. Xi(:,5) should be the answer to fminsearch.
Continuing with the function to minimize the squared difference,
X_av = mean(Xi,2);
fun = @(Xi)(mean(Xi-X_av).^2);
[x,val] = fminsearch(fun,1);
and turns out that val = 1.637758538081846e-09, instead of 5. X = 1.363769531250001.
I have been reading the reference page for fminsearch, but I am bit stacked.
In practice, I will have an array of values as a look up table, that need to be compared to the experimental data. Rows are not important (will be the frequency). What I need is the column number that gives the lowest difference. The data is non-linear by the way, typically as 10log10.
Any suggestions please?
- To make fminsearch as a function of columns, is @(Xi) correct?. - As in my case, how to set up initial x0 values in [x,val]?. Using value from 1 to 8, val output does not change. - X shouldn't be 0 since it's the best solution?
Thanks
0 个评论
采纳的回答
John D'Errico
2017-7-25
A column number is a discrete thing. fminsearch cannot solve that.
Regardless, you don't want to use an optimization (minimization) tool, but more like a root finder, if you are searching for a column of an array. Again, that is not fminsearch.
Just use a loop. Test each column. Take the best. You don't have many columns, so WTP?
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!