Syms function optimization. How to solve function (NLE) for minimum value?
Show older comments
I have derived the equation following syms of variable D s n n_pass as the following function (fun).
fun=100000*(250000000/(549*n*pi*(2*s + 1/1000)) - 2000*n_pass + (625000000*s)/(157*n*(D^2 - 5312662293228351/147573952589676412928)))^2 + 100000*(48000000000/(7*n_pass) - 1000000000000*n*s*((157*D^2)/100 - 834087980036851107/14757395258967641292800))^2 + 7850*D^2*n*n_pass*(2*s + 1/1000) + (102400*n*(2*s + 1/1000))/(627*n_pass*pi)
I have to minize the following function. How to do it using MATLAB optimization functions. Please help?
5 Comments
Torsten
on 23 Jan 2018
Minimize with respect to all 4 variables D, s, n and n_pass ?
Best wishes
Torsten.
Akshayy Garg
on 23 Jan 2018
Walter Roberson
on 23 Jan 2018
matlabFunction with the vars option. List the variables within a vector within a cell array
'vars', {[D, s]}
Akshayy Garg
on 23 Jan 2018
Walter Roberson
on 23 Jan 2018
subs(U, [D, s, n, n_pass], x(1:4))
Answers (1)
Torsten
on 23 Jan 2018
fun=@(D,s,n,n_pass) 1000*....;
x0=[1 1 1 1];
[x,fval,exitflag,output] = fminunc(@(x)fun(x(1),x(2),x(3),x(4)),x0)
Best wishes
Torsten.
2 Comments
Akshayy Garg
on 23 Jan 2018
Edited: Akshayy Garg
on 23 Jan 2018
Torsten
on 23 Jan 2018
Why don't you use the code from above ?
fun=@(D,s,n,n_pas) U won't work, and you forgot the "x0" in your call to "fminunc".
Just do the following:
1) Remove all "syms" declarations in your code.
2) Copy the code from above and insert your fun-definition in the line fun=@(D,s,n,n_pass) 1000*...
3) Run the script.
Best wishes
Torsten.
Categories
Find more on Code Performance in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!