Keep getting the message "undefined function or variable"..I'm trying to create this function to pass to a genetic algorithm to optimise for three variables (k1,k2,k3) but even when I test it I get an error. It saves as a .m file though. What's going wrong?
function y = newFitness(k)
AU = astroConstants(2);
mu = astroConstants(4);
r1 = AU;
psi = pi/2;
phi = pi/2;
theta_dot = sqrt( mu/(((r1/exp(k(1)*sin(phi)))*exp((k(1)*sin(k(2)*(psi + 2*pi*k(3))+phi))))^3) * 1/(tan(atan(k(1)*k(2)*cos(k(2)*(psi + 2*pi*k(3))+phi)))^2 + k(1)*k(2)^2*sin(k(2)*(psi + 2*pi*k(3))+phi) +1) );
y = theta_dot - 94608000;
Edit: Following on from one of the suggestions below, there arises the following information : The function can be found apparently.
So here is the genetic algorithm code that I am trying to pass it on to. I'm not sure why that is important, because before I even touch the GA code, I try and test my function by typing :
Which still gives me an error message of "Undefined function or variable 'newFitness'". But here's the GA code anyways.
objective_function = @newFitness;
nvars = 3;