Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

error using nestedfun and fminsearch

1 view (last 30 days)
Alexandra C
Alexandra C on 11 Jun 2020
Closed: MATLAB Answer Bot on 20 Aug 2021
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

Answers (0)

This question is closed.

Community Treasure Hunt

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

Start Hunting!