Untitled

 avatar
unknown
plain_text
a year ago
435 B
4
Indexable
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
Editor is loading...
Leave a Comment