fminsearch, Function arguments must be symbolic variables, and function body must be sym expression.
Show older comments
Hi All, my code is:
p=10;
spdf = @(x) 3.*(50.^3)./(x+50).^(3+1)./(1-(50./(50+50)).^3);
fun2 = @(x,z) min(x,max(0,fzero(@(y) (100-p-x+y).^(-1)-(2.*z(2)+4.*z(1).*y).^2,0))).^2.*spdf(x);
fun3 = @(z) integral(@(x) fun2(x,z),0,50,'arrayvalued', true);
fun21 = @(x,z) min(x,max(0,fzero(@(y) (100-p-x+y).^(-1)-(2.*z(2)+4.*z(1).*y).^2,0))).*spdf(x);
fun31 = @(z) integral(@(x) fun21(x,z),0,50,'arrayvalued', true);
funfun(z)=@(z) abs((fun31(z)-10).*(fun3(z)-178.57145));
fminsearch(funfun(z),[0.002,0.04])
The error is:
Error using sym/subsindex (line 836)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be symbolic variables, and function body must be sym expression.
Anyone can help me fix my code? Anyhelp is appreciated!
Accepted Answer
More Answers (0)
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!