Hi!
I tried to run the following code but I am getting constantly errors:
clear allclcg = @(V)-( 6.3223*V(4)^2 + 18*V(4) + 12.812 )/V(4);PID = @(V)V(1) + V(2)/V(4) + V(3)*V(4);entrada = @(V)heaviside(V(4));H = @(V)PID(V)*g(V);erro = @(V)entrada(V)/(H(V) + 1);ITAE = @(V)integral(abs(erro(V))*V(4),0,inf);nvar = 4;rng defaultoptions = optimoptions('particleswarm','SwarmSize',100,'MaxIterations',100);lb = [0 0 0 -inf];ub = [100 100 100 inf];[x,fval] = particleswarm(ITAE, nvar,lb ,ub, options);
The error says that the first argument should be a function handle. I verified the datatype using the command 'whos' and it says it's a fucntion handle!! What I am doing wrong?
Best Answer