Info

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

error using nestedfun and fminsearch

1 次查看(过去 30 天)
Alexandra C
Alexandra C 2020-6-11
关闭: MATLAB Answer Bot 2021-8-20
Hi,
I want to use fminsearch with a complex function and the nestedfuntion for optimizing B(1) et B(2)
I have the next error: Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 0-by-0.
a,b,c,d,d2 are variables and Table1 , Table2 are two vectors with the same length.
x0=[0,0];
[B,fval]= Eq(x0,c,d,d2,Table2,a,b,Table1);
function [B,fval] = Eq(x0,c,d,d2,Table2,a,b,Table1)
[B,fval]= fminsearch(@nestedfun,x0);
function y = nestedfun(B)
y=[];
if Table2>= min(a,b)
y = sum((Table1 -(c-B(1).*(d-d2)-B(1).*(d2-B(2))-B(1).*(d2.*Table2)).*(Table2-B(2))-(B(1).*(Table2-d2))*(Table2-d2)./2).^2) ;
else if Table2<= (min(a,b))
y = sum((Table1 -(c-B(1).*(d-d2)-B(1).*(d2-B(2))-B(1).*(d2*Table2)).*(Table2-B(2))).^2) ;
end
end
end
end

回答(0 个)

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by