I have the following code implementing PSO, but it is not working with the simple function: norm(A), where A is a matrix.
This is the code,
fun=@(X) norm([X(1,1),X(1,2); X(2,1), X(2,2)]);
rng default % For reproducibility
lb = [-10,-15];
ub = [15,20];
nvars = 4;
x = particleswarm(fun,nvars,lb,ub)
How could I fix it?
Just change the notation of the function, as the entries of a vector.
fun=@(X) norm([X(1),X(2), X(3), X(4)]);
rng default % For reproducibility
lb = [-10,-15];
ub = [15,20];
nvars = 4;
x = particleswarm(fun,nvars,lb,ub)