Hi, i would like to replace for loops to recursive function. I also would like to have my 5 variables m,al,R0,R1,e in array of (min, max, step,name) because may be in the future i might have more variables so i just add more array and change my function f.
function xm = minfricloop xm = [ Inf Inf Inf Inf Inf Inf]; %For minimization
mmin = 3; mmax = 12; almin = 0.2; almax = 1; R0min = 0.014; R0max = 0.020; R1min = 0.025; R1max = 0.030; emin = 0.5; emax = 0.9; rpm = 20000; ita = 0.1; h0 = 2.51849556599183e-05; n = 5; for v = 0 :20 m = mmin + (mmax-mmin)*(v/(20)); for w = 0 :20 al = almin + (almax-almin)*(w/(20)); for x = 0 :20 R0 = R0min + (R0max-R0min)*(x/(20)); for y = 0 :20 R1 = R1min + (R1max-R1min)*(y/(20)); for z = 0 :20 e = emin + (emax-emin)*(z/(20)); k = (2*pi*e*(R0+R1)/(2*m))*tan(al*pi/180)/h0; f = (R1-R0)*(rpm*2*pi*(R0+R1)/(2*60))*ita*(2*pi*e*(R0+R1)/(2*m))*((6/(k+2))+(4*log(k+1)/k))/h0; if f < xm(6) %For minimization xm = [m al R0 R1 e f]; end end end end end endend
Best Answer