Filter löschen
Filter löschen

Syms function optimization. How to solve function (NLE) for minimum value?

2 Ansichten (letzte 30 Tage)
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 Kommentare
Akshayy Garg
Akshayy Garg am 23 Jan. 2018
I know that. But I alraedy have the equation with the syms variable in U as follows: U =
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 want to replace D,s,n,n_pass in the equation to x(1),x(2),x(3), x(4) directly. How to do that?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Torsten
Torsten am 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 Kommentare
Akshayy Garg
Akshayy Garg am 23 Jan. 2018
Bearbeitet: Akshayy Garg am 23 Jan. 2018
I got my earlier function stored in var U.I tried this way: U=1000*....; % I cannot write this directly in fun because I get the values from other equations also. This is the final objective function fun=@(D,s,n,n_pass)U x0=[10e-3 1e-3 5e3 20] [x,fval,exitflag,output]=fminunc(@(x)fun(x(1),x(2),x(3),x(4)),x0)
Did not work?
Regards Akshayy
Torsten
Torsten am 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.

Melden Sie sich an, um zu kommentieren.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by