Info
此问题已关闭。 请重新打开它进行编辑或回答。
error using nestedfun and fminsearch
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!