Optimize a function with a sum of series
Show older comments
Hello. Basically, I need to optimize the following function
The minimum value for 'n' is 2. Imagine we have n = 25. I have a sum of series so I tried the following:
syms i n
x0=[2:25];
i=[1:25];
f1= @(x)(x(1)+7)^8
f2 = @(x)((0.01*x(i)-i)^2)/i
All looks good until I try to sum both parts
fun = f1+symsum(f2,i,2,25);
Check for missing argument or incorrect argument data type in call to function 'symsum'.
If the previous step was correct, I would call "fminunc(fun,x0);" to optimize the function.
Could you explain why I get this error? 'i' should be a symbolic variable because of being created by syms call. Set of 'x' is defined. I must have missed something but can't find out what.
2 Comments
Paul
on 12 Dec 2021
For n = 25, it looks like y is function of x1 - x25, i.e.,
. Is that correct?
What is
? That term doesn't show up in the equation for y.
Dmytro Stovolos
on 13 Dec 2021
Accepted Answer
More Answers (0)
Categories
Find more on Solver Outputs and Iterative Display 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!