How to find parameters of the following coefficient based on optimization tool?

7 Ansichten (letzte 30 Tage)
Hi everyone, I have the following input and function, my purpose is to calculate the value of a,m and n which are scalars using curve fitting in matlab. I have:
ew=[0.679 0.613 0.613 0.501 0.497 0.50 0.389 0.386 0.386 0.391 0.390 0.288 0.288 0.288 0.289 0.289]; Hw=[0.757 0.669 0.71 0.577 0.57 0.60 0.50 0.55 0.52 0.50 0.476 0.353 0.388 0.379 0.431 0.371]; k=[0.217 0.217 0.217 0.163 0.163 0.163 0.131 0.131 0.131 0.131 0.131 0.109 0.109 0.109 0.109 0.109];
Hw=[ew*(1+0.36(1-ew))]*C; C=exp[-a*(k^m)*(1-ew)^n];
any help would be appreciated.
  1 Kommentar
Alan Weiss
Alan Weiss am 11 Apr. 2016
Please format your question using the {} Code button so that we might read it more easily.
Alan Weiss
MATLAB mathematical toolbox documentation

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Roger Stafford
Roger Stafford am 12 Apr. 2016
Define the following sum of squares of differences:
ew=[0.679 0.613 0.613 0.501 0.497 0.50 0.389 0.386 0.386 0.391 0.390 0.288 0.288 0.288 0.289 0.289];
Hw=[0.757 0.669 0.71 0.577 0.57 0.60 0.50 0.55 0.52 0.50 0.476 0.353 0.388 0.379 0.431 0.371];
k= [0.217 0.217 0.217 0.163 0.163 0.163 0.131 0.131 0.131 0.131 0.131 0.109 0.109 0.109 0.109 0.109];
function s = myfun(a,m,n)
s = sum((Hw-ew.*(1+0.36(1-ew)).*exp[-a*(k.^m).*(1-ew).^n)).^2);
return
and then use that subfunction for optimization of a, m, and n using 'fminsearch' or 'fminunc'. Their descriptions can be found at:
http://www.mathworks.com/help/matlab/ref/fminsearch.html
http://www.mathworks.com/help/optim/ug/fminunc.html

Parham Babakhani Dehkordi
Parham Babakhani Dehkordi am 12 Apr. 2016
Thank you Roger for your help,but I still have a problem to get a solution, I arranged my code with initial guesses for a=0.31,m=1 and n=0.7 and also I considered a=x(1), m=x(2) and n=x(3) as follows:
for i=1:16
x =fminsearch(@(x) (Hw(i)-(ew(i)*(1+0.36*(1-ew(i)))))*exp(-x(1)*k(i)^x(2)*(1-ew(i))^x(3)), [0.31 1.0 0.7])
end
there is an error which says Error: File: fminsearch.m Line: 31 Column: 5
Function definitions are not permitted in this context.
Actually I could not properly use handle function directly to pass it through function function (in this case fminsearch). Sorry Alan, I am new user to Matlab.

Community Treasure Hunt

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

Start Hunting!

Translated by