Info

此问题已关闭。 请重新打开它进行编辑或回答。

this code is giving same values of x irrespective of change in the power of xdata in fun???i am changing power 0.5 to 0.9 no change in output??

1 次查看(过去 30 天)
xdata =[10.^(-5) 10.^(-4) 10.^(-3) 10.^(-2) 10.^(-1) 1];
ydata=(0.2575./((xdata.^2)+(0.333.*xdata)+1));
fun=@(x)sum(x(1)./((x(2).*xdata.^1.5+x(3).*xdata.^0.5+1)- ydata).^2);
rng default % For reproducibility
nvars = 3;
LB = [0.2;0.2; 0.2];
UB = [5; 5; 5];
options = optimoptions('particleswarm','SwarmSize',50,'HybridFcn',@fmincon);
x = particleswarm(fun,nvars,LB,UB,options)

回答(1 个)

John D'Errico
John D'Errico 2018-4-13
The answer is always to think clearly about what you did. Look at the numbers.
xdata =[10.^(-5) 10.^(-4) 10.^(-3) 10.^(-2) 10.^(-1) 1];
ydata=(0.2575./((xdata.^2)+(0.333.*xdata)+1));
ydata =
0.2575 0.25749 0.25741 0.25662 0.24681 0.11037
So almost all of ydata is CONSTANT. All but one element was virtually the same identical value. So you are trying to fit a curve that has essentially only two pieces of information in it.
fun=@(x)sum(x(1)./((x(2).*xdata.^1.5+x(3).*xdata.^0.5+1)- ydata).^2);
Almost all of xdata are tiny numbers, then raising it to a power makes it even smaller. But as well, it becomes effectively unimportant in the computation. You won't see much difference if you use xdata.^1.5 or xdata.^2 in the fit.
I cannot show you exactly what happens, because I don't have that toolbox.

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by