Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
435 B
2
Indexable
Never
function z=Sphere(x, y, d)
      switch y
        case 1
            z=sum(x.^2);

        case 2
            z=sum(abs(x))+prod(abs(x));

        case 3
            z=0;
            for i=1:d
                z=z+sum(x(1:i))^2;
            end
            
        case 4
            z=max(abs(x));

        case 5
            z=sum(100*(x(2:d)-(x(1:d-1).^2)).^2+(x(1:d-1)-1).^2);
              
              
end
Leave a Comment